mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-10 11:51:52 +00:00
LIBRETRO: Add checks for LibretroPalette colors ptr
This commit is contained in:
parent
1aa02751ea
commit
3fffa3de00
@ -49,12 +49,14 @@ public:
|
||||
|
||||
class LibretroPalette {
|
||||
public:
|
||||
const byte *_prevColorsSource;
|
||||
unsigned char _colors[256 * 3];
|
||||
LibretroPalette(void);
|
||||
~LibretroPalette(void) {};
|
||||
void set(const byte *colors, uint start, uint num);
|
||||
void get(byte *colors, uint start, uint num) const;
|
||||
unsigned char *getColor(uint aIndex) const;
|
||||
void reset(void) { _prevColorsSource = NULL; }
|
||||
};
|
||||
|
||||
class OSystem_libretro : public EventsBaseBackend, public PaletteManager {
|
||||
|
@ -123,6 +123,8 @@ void OSystem_libretro::engineInit() {
|
||||
ConfMan.setBool("original_gui", false);
|
||||
retro_log_cb(RETRO_LOG_INFO, "\"original_gui\" setting forced to false\n");
|
||||
}
|
||||
_mousePalette.reset();
|
||||
_gamePalette.reset();
|
||||
}
|
||||
|
||||
void OSystem_libretro::engineDone() {
|
||||
|
@ -198,12 +198,26 @@ static INLINE void copyRectToSurface(uint8 *pixels, int out_pitch, const uint8 *
|
||||
} while (--h);
|
||||
}
|
||||
|
||||
LibretroPalette::LibretroPalette() {
|
||||
LibretroPalette::LibretroPalette() : _prevColorsSource(NULL){
|
||||
memset(_colors, 0, sizeof(_colors));
|
||||
}
|
||||
|
||||
void LibretroPalette::set(const byte *colors, uint start, uint num) {
|
||||
memcpy(_colors + start * 3, colors, num * 3);
|
||||
/* TODO: This check is a workaround to handle a SEGFAULT in iOS due to the call from SmushPlayer::play in scumm engine,
|
||||
caused by the corruption of start argument (and consequently colors ptr). Root cause to be investigated. */
|
||||
if (start > 255) {
|
||||
start = 0;
|
||||
colors=_prevColorsSource;
|
||||
}else
|
||||
_prevColorsSource = colors;
|
||||
|
||||
if (num>256)
|
||||
num=256;
|
||||
|
||||
if (colors)
|
||||
memcpy(_colors + start * 3, colors, num * 3);
|
||||
else
|
||||
LIBRETRO_G_SYSTEM->logMessage(LogMessageType::kError,"LibretroPalette colors ptr is NULL\n");
|
||||
}
|
||||
|
||||
void LibretroPalette::get(byte *colors, uint start, uint num) const {
|
||||
|
Loading…
Reference in New Issue
Block a user