commit 64f3c7719d5c78a2fb962d66ec7d04f7bb15db8f
parent 961ee6c2ea156ff13f4dc54ddde5f1e9e4cffe35
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Wed, 16 Oct 2024 17:42:49 +0200
libmach/coff32: Accept empty rels and lines
A stripped file don't have relocation and line info,
and in that case the pointers rels and lines are
NULL and they cannot be indirected.
Diffstat:
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/libmach/coff32/coff32del.c b/src/libmach/coff32/coff32del.c
@@ -18,8 +18,10 @@ coff32del(Obj *obj)
free(coff->strtbl);
for (i = 0; i < coff->hdr.f_nscns; i++) {
- free(coff->rels[i]);
- free(coff->lines[i]);
+ if (coff->rels)
+ free(coff->rels[i]);
+ if (coff->lines)
+ free(coff->lines[i]);
}
free(coff->rels);
free(coff->lines);
diff --git a/src/libmach/coff32/coff32strip.c b/src/libmach/coff32/coff32strip.c
@@ -27,8 +27,10 @@ coff32strip(Obj *obj)
hdr->f_flags |= F_RELFLG | F_LMNO | F_LSYMS;
for (i = 0; i < coff->hdr.f_nscns; i++) {
- free(coff->rels[i]);
- free(coff->lines[i]);
+ if (coff->rels)
+ free(coff->rels[i]);
+ if (coff->lines)
+ free(coff->lines[i]);
}
free(coff->ents);