[PATCH 7/7] libcpu: Free unused new bitfield on error in i386_parse.y new_bitfield.

Mark Wielaard mark@klomp.org
Sun May 10 19:53:40 GMT 2020


GCC10 -fanalyzer detected we didn't free the newly created bitfield
on error. Make sure to free it before returning.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 libcpu/ChangeLog    | 4 ++++
 libcpu/i386_parse.y | 1 +
 2 files changed, 5 insertions(+)

diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog
index a8b2b951..a342b7f6 100644
--- a/libcpu/ChangeLog
+++ b/libcpu/ChangeLog
@@ -1,3 +1,7 @@
+2020-05-09  Mark Wielaard  <mark@klomp.org>
+
+	* i386_parse.y (new_bitfield): Call free newp on error.
+
 2020-04-16  Mark Wielaard  <mark@klomp.org>
 
 	* i386_disasm.c (i386_disasm): Replace assert with goto invalid_op
diff --git a/libcpu/i386_parse.y b/libcpu/i386_parse.y
index 910d5458..90c7bd93 100644
--- a/libcpu/i386_parse.y
+++ b/libcpu/i386_parse.y
@@ -579,6 +579,7 @@ new_bitfield (char *name, unsigned long int num)
       error (0, 0, "%d: duplicated definition of bitfield '%s'",
 	     i386_lineno, name);
       free (name);
+      free (newp);
       return;
     }
 
-- 
2.20.1



More information about the Elfutils-devel mailing list