From 2a892a23b1acccc0ac3700d28c69a7b3c69ea616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigrid=20Solveig=20Hafl=C3=ADnud=C3=B3ttir?= Date: Tue, 29 Mar 2022 19:23:59 +0200 Subject: [PATCH] uxnemu: fix a memory leak (ram) in start() and reduce types clutter --- src/uxnemu.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/uxnemu.c b/src/uxnemu.c index 26aa1a3..6829c29 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -263,7 +263,8 @@ load(Uxn *u, char *rom) static int start(Uxn *u, char *rom) { - if(!uxn_boot(u, (Uint8 *)calloc(0x10000, sizeof(Uint8)))) + free(u->ram); + if(!uxn_boot(u, calloc(0x10000, 1))) return error("Boot", "Failed to start uxn."); if(!load(u, rom)) return error("Boot", "Failed to load rom."); @@ -474,7 +475,7 @@ int main(int argc, char **argv) { SDL_DisplayMode DM; - Uxn u; + Uxn u = {0}; int i, loaded = 0; if(!init())