diff --git a/src/generic/paletteg.cpp b/src/generic/paletteg.cpp index af3fe56e93..6b3530e864 100644 --- a/src/generic/paletteg.cpp +++ b/src/generic/paletteg.cpp @@ -131,8 +131,11 @@ bool wxPalette::GetRGB(int pixel, unsigned char *green, unsigned char *blue) const { - if (!m_refData) return false; - if (pixel >= M_PALETTEDATA->m_count) return false; + if ( !m_refData ) + return false; + + if ( pixel < 0 || pixel >= M_PALETTEDATA->m_count ) + return false; wxPaletteEntry& p = M_PALETTEDATA->m_entries[pixel]; if (red) *red = p.red; diff --git a/src/msw/palette.cpp b/src/msw/palette.cpp index 6d430f9b7a..e4584a5bb5 100644 --- a/src/msw/palette.cpp +++ b/src/msw/palette.cpp @@ -156,7 +156,7 @@ bool wxPalette::GetRGB(int index, if ( !m_refData ) return false; - if (index < 0 || index > 255) + if ( index < 0 || index >= GetColoursCount() ) return false; PALETTEENTRY entry; diff --git a/src/osx/palette.cpp b/src/osx/palette.cpp index e0519daa13..0d388946a3 100644 --- a/src/osx/palette.cpp +++ b/src/osx/palette.cpp @@ -122,7 +122,7 @@ bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsi if ( !m_refData ) return false; - if (index < 0 || index >= M_PALETTEDATA->m_count) + if ( index < 0 || index >= M_PALETTEDATA->m_count ) return false; const wxColour& col = M_PALETTEDATA->m_palette[index] ; diff --git a/src/x11/palette.cpp b/src/x11/palette.cpp index 1cdf8bc4ad..1559ecac17 100644 --- a/src/x11/palette.cpp +++ b/src/x11/palette.cpp @@ -242,7 +242,7 @@ bool wxPalette::GetRGB(int index, if ( !m_refData ) return false; - if (index < 0 || index > 255) + if ( index < 0 || index >= GetColoursCount() ) return false; wxList::compatibility_iterator node = M_PALETTEDATA->m_palettes.GetFirst();