From fd22cf4915bf70a534b4ca56ac4f838c1a340e0e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 1 Mar 2011 00:02:52 +0000 Subject: [PATCH] Relax the restriction on the number of colours in wxMSW wxPalette. Refuse to create palettes with more than 65536 colours and not 256 ones. It doesn't seem very useful to use more than 256 of them anyhow as any colours above index 255 can't be accessed via GetRGB() but don't break the palette creation with more colours in the stable branch without a good reason, maybe someone makes some use of this. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@67095 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/palette.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/msw/palette.cpp b/src/msw/palette.cpp index 271a1e0b17..08f440d448 100644 --- a/src/msw/palette.cpp +++ b/src/msw/palette.cpp @@ -79,7 +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 ) + // The number of colours in LOGPALETTE is a WORD so we can't create + // palettes with more entries than USHRT_MAX. + if ( n < 0 || n > 65535 ) return false; UnRef();