[Scummvm-git-logs] scummvm master -> 3fffa3de006a72ebe113a50b2b006b39e89b8aaf
spleen1981
noreply at scummvm.org
Sun Nov 12 02:30:37 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3fffa3de00 LIBRETRO: Add checks for LibretroPalette colors ptr
Commit: 3fffa3de006a72ebe113a50b2b006b39e89b8aaf
https://github.com/scummvm/scummvm/commit/3fffa3de006a72ebe113a50b2b006b39e89b8aaf
Author: Giovanni Cascione (ing.cascione at gmail.com)
Date: 2023-11-12T03:29:59+01:00
Commit Message:
LIBRETRO: Add checks for LibretroPalette colors ptr
Changed paths:
backends/platform/libretro/include/libretro-os.h
backends/platform/libretro/src/libretro-os-base.cpp
backends/platform/libretro/src/libretro-os-graphics.cpp
diff --git a/backends/platform/libretro/include/libretro-os.h b/backends/platform/libretro/include/libretro-os.h
index f1ad64de008..d8d926c1425 100644
--- a/backends/platform/libretro/include/libretro-os.h
+++ b/backends/platform/libretro/include/libretro-os.h
@@ -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 {
diff --git a/backends/platform/libretro/src/libretro-os-base.cpp b/backends/platform/libretro/src/libretro-os-base.cpp
index 6b2962f2906..c200a92e258 100644
--- a/backends/platform/libretro/src/libretro-os-base.cpp
+++ b/backends/platform/libretro/src/libretro-os-base.cpp
@@ -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() {
diff --git a/backends/platform/libretro/src/libretro-os-graphics.cpp b/backends/platform/libretro/src/libretro-os-graphics.cpp
index c93127fc4cc..9f02627963e 100644
--- a/backends/platform/libretro/src/libretro-os-graphics.cpp
+++ b/backends/platform/libretro/src/libretro-os-graphics.cpp
@@ -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 {
More information about the Scummvm-git-logs
mailing list