Skip to content

Commit

Permalink
bugfix: Fixed memory leak when using AROS rom
Browse files Browse the repository at this point in the history
When no Kickstart was found and the AROS ROM was used, the memory allocated was never freed
  • Loading branch information
midwan authored Nov 1, 2023
1 parent bf3ab27 commit 3cf3ed8
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1781,7 +1781,10 @@ static bool load_kickstart_replacement(void)
}
struct zfile* f = zfile_fopen_data(path, arosrom_len, arosrom);
if (!f)
{
xfree(arosrom);
return false;
}
#else
f = zfile_fopen_data(_T("aros.gz"), arosrom_len, arosrom);
if (!f)
Expand All @@ -1800,6 +1803,7 @@ static bool load_kickstart_replacement(void)

#ifdef AMIBERRY
zfile_fclose(f);
xfree(arosrom);
get_rom_path(path, MAX_DPATH);
strcat(path, "aros-rom.bin");
arosrom = zfile_load_file(path, &arosrom_len);
Expand All @@ -1810,14 +1814,18 @@ static bool load_kickstart_replacement(void)
}
f = zfile_fopen_data(path, arosrom_len, arosrom);
if (!f)
{
xfree(arosrom);
return false;
}
#endif

kickmem_bank.reserved_size = ROM_SIZE_512;
kickmem_bank.mask = ROM_SIZE_512 - 1;
read_kickstart(f, kickmem_bank.baseaddr, ROM_SIZE_512, 1, 0);

zfile_fclose(f);
xfree(arosrom);

seriallog = -1;

Expand Down

0 comments on commit 3cf3ed8

Please sign in to comment.