diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2016-02-11 20:20:10 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2016-02-11 20:20:10 -0800 |
commit | f30d96d1c025d1a9c9453ed225f78d6b156da5f9 (patch) | |
tree | 78c320454cb20f7293c76347f98407da75fb91a5 | |
parent | 97577e82d7230e5b3ef0947c8d62b9a3326fe4a1 (diff) | |
download | nasm-machofix.tar.gz |
outmac64.c: Fix memory clobber bug, clean up memory freemachofix
Fix an array that was way too small resulting in memory overwrite
errors, and free a few more dynamic data structures.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | output/outmac64.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/output/outmac64.c b/output/outmac64.c index 76fa7ad3..5c8a0dc6 100644 --- a/output/outmac64.c +++ b/output/outmac64.c @@ -1016,7 +1016,7 @@ static void macho_calculate_sizes (void) } /* Create a table of sections by file index to avoid linear search */ - sectstab = nasm_malloc(seg_nsects64 + 1); + sectstab = nasm_malloc((seg_nsects64 + 1) * sizeof(*sectstab)); sectstab[0] = NULL; for (s = sects, fi = 1; s != NULL; s = s->next, fi++) sectstab[fi] = s; @@ -1456,14 +1456,15 @@ static void macho_cleanup(int debuginfo) saa_free(strs); raa_free(extsyms); - if (syms) { - while (syms->next) { + while (syms) { sym = syms; syms = syms->next; - nasm_free (sym); } -} + + nasm_free(extdefsyms); + nasm_free(undefsyms); + nasm_free(sectstab); } /* Debugging routines. */ |