PR29261, memory leak in parse_stab_struct_fields

Alan Modra amodra@gmail.com
Mon Jun 20 01:50:30 GMT 2022


	PR 29261
	* stabs.c (parse_stab_struct_fields): Free "fields" on failure path.

diff --git a/binutils/stabs.c b/binutils/stabs.c
index 796ff85b86a..bf3f578cbcc 100644
--- a/binutils/stabs.c
+++ b/binutils/stabs.c
@@ -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;
     }

-- 
Alan Modra
Australia Development Lab, IBM


More information about the Binutils mailing list