From 376c9e2181626862c081b2ddf8be442208ef3afd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 19 Nov 2013 13:12:52 +0000 Subject: [PATCH] Don't allocate way too much memory in wxVector::reserve(). We multiplied the number of items by the size of each element twice, once in wxVector::reserve() itself and once in Ops::Realloc() it called, so we allocated much more memory than actually needed. Fix this by passing the number of elements to Ops::Realloc(). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@75245 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + include/wx/vector.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index a986c14b9c..5cee0aac01 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -577,6 +577,7 @@ Major new features in this release All: - Fix wxSocket::WaitForAccept() in non-main thread (Hajo Kirchhoff). +- Fix memory overallocation in wxVector::reserve() (Nigel Paton). All (GUI): diff --git a/include/wx/vector.h b/include/wx/vector.h index dffb19fc9d..e81cafb082 100644 --- a/include/wx/vector.h +++ b/include/wx/vector.h @@ -327,7 +327,7 @@ public: if ( m_capacity + increment > n ) n = m_capacity + increment; - m_values = Ops::Realloc(m_values, n * sizeof(value_type), m_size); + m_values = Ops::Realloc(m_values, n, m_size); m_capacity = n; }