From 94ed0463d0570ef2fc1e0de9992a964ffeeb65c2 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sun, 4 Apr 2021 21:09:40 +0200 Subject: [PATCH] Check if index is in the range prior to erasing the image from wxImageList This is to avoid memory errors in wxVector. --- src/generic/imaglist.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/generic/imaglist.cpp b/src/generic/imaglist.cpp index d15d20fa33..b72dd29d51 100644 --- a/src/generic/imaglist.cpp +++ b/src/generic/imaglist.cpp @@ -265,6 +265,9 @@ wxGenericImageList::Replace(int index, bool wxGenericImageList::Remove( int index ) { + if ( index < 0 || (size_t)index >= m_images.size() ) + return false; + m_images.erase(m_images.begin() + index); return true;