summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2020-05-09 23:31:05 +0200
committerMark Wielaard <mark@klomp.org>2020-05-14 14:30:57 +0200
commit5d3b808238b01d27c0ee97e5415e4b6aac410781 (patch)
tree028d628e2c08c8b1021d7b96761dcc43f924f6c6
parentdca13089f93807f99f447b9b033ac27a43ff913f (diff)
downloadelfutils-5d3b808238b01d27c0ee97e5415e4b6aac410781.tar.gz
libcpu: Free unused new bitfield on error in i386_parse.y new_bitfield.
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>
-rw-r--r--libcpu/ChangeLog4
-rw-r--r--libcpu/i386_parse.y1
2 files changed, 5 insertions, 0 deletions
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;
}