We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent cc495c2 commit 5803501Copy full SHA for 5803501
Core/gb.c
@@ -58,7 +58,13 @@ static char *default_input_callback(GB_gameboy_t *gb)
58
59
if (getline(&expression, &size, stdin) == -1) {
60
/* The user doesn't have STDIN or used ^D. We make sure the program keeps running. */
61
- free(expression);
+
62
+ /* Some implementations may allocate expressions even on getline failure,
63
+ and other implementations may crash on free(NULL). Free expression if
64
+ it was allocated. */
65
+ if (expression) {
66
+ free(expression);
67
+ }
68
GB_set_async_input_callback(gb, NULL); /* Disable async input */
69
return strdup("c");
70
}
0 commit comments