Browse Source

MeshTools: check out-of-range access in MeshTools::duplicate().

pull/51/head
Vladimír Vondruš 12 years ago
parent
commit
14e4e78b6b
  1. 5
      src/Magnum/MeshTools/Duplicate.h

5
src/Magnum/MeshTools/Duplicate.h

@ -30,6 +30,7 @@
*/
#include <vector>
#include <Corrade/Utility/Assert.h>
#include "Magnum/Types.h"
@ -45,8 +46,10 @@ index array `{1, 1, 0, 3, 2, 2}` will be converted to `{b, b, a, d, c, c}`.
template<class T> std::vector<T> duplicate(const std::vector<UnsignedInt>& indices, const std::vector<T>& data) {
std::vector<T> out;
out.reserve(indices.size());
for(const UnsignedInt index: indices)
for(const UnsignedInt index: indices) {
CORRADE_ASSERT(index < data.size(), "MeshTools::duplicate(): index out of range", out);
out.push_back(data[index]);
}
return out;
}

Loading…
Cancel
Save