git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit 58035018aa4593abdf07a70148faae9836bf2590
parent cc495c2602ec2f0edc3ef2a22507bed5bbfd097d
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Fri, 14 Nov 2025 20:46:34 +0200

Make sure we don't crash on slightly-off-standard libc implementations

Diffstat:
MCore/gb.c8+++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Core/gb.c b/Core/gb.c @@ -58,7 +58,13 @@ static char *default_input_callback(GB_gameboy_t *gb) if (getline(&expression, &size, stdin) == -1) { /* The user doesn't have STDIN or used ^D. We make sure the program keeps running. */ - free(expression); + + /* Some implementations may allocate expressions even on getline failure, + and other implementations may crash on free(NULL). Free expression if + it was allocated. */ + if (expression) { + free(expression); + } GB_set_async_input_callback(gb, NULL); /* Disable async input */ return strdup("c"); }

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.