From 14e4e78b6b255ff50d74197e77136228c2f9c371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 4 Mar 2014 13:01:22 +0100 Subject: [PATCH] MeshTools: check out-of-range access in MeshTools::duplicate(). --- src/Magnum/MeshTools/Duplicate.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Magnum/MeshTools/Duplicate.h b/src/Magnum/MeshTools/Duplicate.h index 4d67ab583..7ba7772c2 100644 --- a/src/Magnum/MeshTools/Duplicate.h +++ b/src/Magnum/MeshTools/Duplicate.h @@ -30,6 +30,7 @@ */ #include +#include #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 std::vector duplicate(const std::vector& indices, const std::vector& data) { std::vector 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; }