Fix checks for wxPalette index validity
Consistently check that the index is valid in all ports, instead of using hard-coded 255 rather than the actual number of colours in some of them and forgetting to check that the index is positive in others. Closes #19198.
This commit is contained in:
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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] ;
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user