PR29261, memory leak in parse_stab_struct_fields
authorAlan Modra <amodra@gmail.com>
Mon, 20 Jun 2022 01:09:13 +0000 (10:39 +0930)
committerAlan Modra <amodra@gmail.com>
Mon, 20 Jun 2022 01:09:52 +0000 (10:39 +0930)
PR 29261
* stabs.c (parse_stab_struct_fields): Free "fields" on failure path.

binutils/stabs.c

index 796ff85b86a209cc61f361def48f59df29f0a41b..bf3f578cbccf01da7cba58812f359075d9b97afa 100644 (file)
@@ -2367,7 +2367,10 @@ parse_stab_struct_fields (void *dhandle,
 
       if (! parse_stab_one_struct_field (dhandle, info, pp, p, fields + c,
                                         staticsp, p_end))
-       return false;
+       {
+         free (fields);
+         return false;
+       }
 
       ++c;
     }