From b3d9a4a6eb5df555416644f2a52c2fe2ddc21812 Mon Sep 17 00:00:00 2001 From: Ry Date: Thu, 13 Jul 2023 23:58:59 -0700 Subject: [PATCH] kernel/fxf: Free memory used by binary if relocation fails --- kernel/fxf/launch.asm | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/kernel/fxf/launch.asm b/kernel/fxf/launch.asm index d38900a..858c27b 100644 --- a/kernel/fxf/launch.asm +++ b/kernel/fxf/launch.asm @@ -102,7 +102,7 @@ launch_fxf_from_open_file_1: mov r0, [launch_fxf_binary_ptr] call parse_fxf_binary cmp r0, 0 - ifz jmp launch_fxf_from_disk_file_error + ifz jmp launch_fxf_from_disk_reloc_error ; create a new task mov r1, r0 @@ -139,6 +139,20 @@ launch_fxf_from_disk_file_error: pop r1 mov r0, 0xFFFFFFFF ret +launch_fxf_from_disk_reloc_error: + mov r0, [launch_fxf_binary_ptr] + call free_memory + mov r0, [launch_fxf_stack_ptr] + call free_memory + + pop r6 + pop r5 + pop r4 + pop r3 + pop r2 + pop r1 + mov r0, 0xFFFFFFFF + ret launch_fxf_struct_ptr: data.32 0 launch_fxf_struct: data.fill 0, 32