From 2a35360c3dde48139828c3e87fc0025bcbc8aa6d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 27 Feb 2011 13:10:43 +0000 Subject: [PATCH] Refuse to create palettes with more than 256 colours. Creating palettes with more than USHRT_MAX could result in memory corruption and there is really no reason to allow more than 256 of them anyhow as we already check that the color index is in 0..255 range in GetRGB(). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@67071 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/palette.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/msw/palette.cpp b/src/msw/palette.cpp index d72f0adc40..271a1e0b17 100644 --- a/src/msw/palette.cpp +++ b/src/msw/palette.cpp @@ -79,6 +79,9 @@ int wxPalette::GetColoursCount() const bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) { + if ( n < 0 || n > 255 ) + return false; + UnRef(); #if defined(__WXMICROWIN__)