From cd22c140f07c273026b403f74f98a4716b973bd0 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 13 Aug 2024 00:16:42 -0700 Subject: [PATCH] GB: Fix potential null pointer deref --- src/gb/gb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gb/gb.c b/src/gb/gb.c index ea0a4d7df..282fc45c1 100644 --- a/src/gb/gb.c +++ b/src/gb/gb.c @@ -1119,11 +1119,11 @@ bool GBIsROM(struct VFile* vf) { void GBGetGameInfo(const struct GB* gb, struct mGameInfo* info) { memset(info, 0, sizeof(*info)); - const struct GBCartridge* cart = NULL; - if (gb->memory.rom) { - cart = (const struct GBCartridge*) &gb->memory.rom[0x100]; + if (!gb->memory.rom) { + return; } + const struct GBCartridge* cart = (const struct GBCartridge*) &gb->memory.rom[0x100]; if (cart->cgb == 0xC0) { strlcpy(info->system, "CGB", sizeof(info->system)); } else {