From 2e5f5c0cefff728097068e447aab4d75678a671a Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 7 Nov 2020 03:39:33 -0800 Subject: [PATCH] Libretro: Only set camera peripheral when it is available Otherwise, if the frontend does not support GET_CAMERA_INTERFACE, the start and stop functions are NULL, causing a crash when a gameboy ROM is unloaded. --- src/platform/libretro/libretro.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/platform/libretro/libretro.c b/src/platform/libretro/libretro.c index 0d2d0e60b..0b59dd4ce 100644 --- a/src/platform/libretro/libretro.c +++ b/src/platform/libretro/libretro.c @@ -606,9 +606,10 @@ bool retro_load_game(const struct retro_game_info* game) { cam.width = GBCAM_WIDTH; cam.caps = 1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER; cam.frame_raw_framebuffer = _updateCamera; - core->setPeripheral(core, mPERIPH_IMAGE_SOURCE, &imageSource); + if (environCallback(RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE, &cam)) { + core->setPeripheral(core, mPERIPH_IMAGE_SOURCE, &imageSource); + } - environCallback(RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE, &cam); const char* modelName = mCoreConfigGetValue(&core->config, "gb.model"); struct GB* gb = core->board; -- 2.29.2