From a855f682c673a3ab59307a0212ff9a6f56632182 Mon Sep 17 00:00:00 2001 From: Elliot Nunn Date: Sat, 3 Feb 2018 11:40:54 +0800 Subject: [PATCH] Fix bug where RomLink handles weren't locked Pointers to relocatable blocks were being kept and re-used! Now HLock is correctly used to keep the blocks in place. This is Memory Manager 101. --- Tools/ToolSource/RomLink.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Tools/ToolSource/RomLink.c b/Tools/ToolSource/RomLink.c index c9a630f..6a6b619 100644 --- a/Tools/ToolSource/RomLink.c +++ b/Tools/ToolSource/RomLink.c @@ -61,6 +61,9 @@ void get_program(unsigned char **prog_p, long *len_p, unsigned char *name) fprintf(stderr, "Could not find program \"%.*s\"\n", *name, name+1); } + MoveHHi(hdl); + HLock(hdl); + *prog_p = *(unsigned char **)hdl; *len_p = GetHandleSize(hdl); } @@ -68,7 +71,9 @@ void get_program(unsigned char **prog_p, long *len_p, unsigned char *name) void free_program(unsigned char *prog) { - DisposeHandle(RecoverHandle((Ptr)prog)); + Handle hdl = RecoverHandle((Ptr)prog); + HUnlock(hdl); + DisposeHandle(hdl); }