diff options
-rw-r--r-- | graphics/paletteman.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/graphics/paletteman.cpp b/graphics/paletteman.cpp index 320b3b6497..23bd7534a7 100644 --- a/graphics/paletteman.cpp +++ b/graphics/paletteman.cpp @@ -85,12 +85,13 @@ void PaletteManager::replaceCursorPalette(const byte *colors, uint start, uint n } Palette *pal = _cursorPaletteStack.top(); + uint size = 4 * num; - if (pal->_size < 4 * num) { + if (pal->_size < size) { + // Could not re-use the old buffer. Create a new one. delete pal->_colors; - pal->_colors = new byte[4 * num]; - } else { - pal->_size = 4 * num; + pal->_colors = new byte[size]; + pal->_size = size; } pal->_start = start; |