libmach/coff32: Free lines and relocations - scc - simple c99 compiler
 (HTM) git clone git://git.simple-cc.org/scc
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit d453c845befbaa9a03eb974df569ebd41c9d7a49
 (DIR) parent 38ab22d6380b1d1c6fa232fa2ee5ef42b4faa77d
 (HTM) Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
       Date:   Fri, 22 Mar 2024 08:02:16 +0100
       
       libmach/coff32: Free lines and relocations
       
       Every section has a different set of line info and relocations, and for
       that reason is required to free every groud independently but we were
       freeing only the array of arrays.
       
       Diffstat:
         M src/libmach/coff32/coff32del.c      |       8 ++++++++
         M src/libmach/coff32/coff32strip.c    |       5 +++++
       
       2 files changed, 13 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/src/libmach/coff32/coff32del.c b/src/libmach/coff32/coff32del.c
       @@ -9,12 +9,20 @@
        void
        coff32del(Obj *obj)
        {
       +        int i;
                struct coff32 *coff = obj->data;
        
                if (coff) {
                        free(coff->scns);
                        free(coff->ents);
                        free(coff->strtbl);
       +
       +                for (i = 0; i < coff->hdr.f_nscns; i++) {
       +                        free(coff->rels[i]);
       +                        free(coff->lines[i]);
       +                }
       +                free(coff->rels);
       +                free(coff->lines);
                }
                free(obj->data);
                obj->data = NULL;
 (DIR) diff --git a/src/libmach/coff32/coff32strip.c b/src/libmach/coff32/coff32strip.c
       @@ -26,6 +26,11 @@ coff32strip(Obj *obj)
                hdr->f_symptr = 0;
                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]);
       +        }
       +
                free(coff->ents);
                free(coff->rels);
                free(coff->lines);