[committed] analyzer: add regression test [PR99269]

David Malcolm dmalcolm@redhat.com
Tue Nov 30 22:54:36 GMT 2021


Successfully regrtested on x86_64-pc-linux-gnu.
Pushed to trunk as r12-5641-g9603bccba62e250d0ff64863a1730a167d571a25.

gcc/testsuite/ChangeLog:
	PR analyzer/99269
	* gcc.dg/analyzer/pr99269.c: New test.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
 gcc/testsuite/gcc.dg/analyzer/pr99269.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/analyzer/pr99269.c

diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99269.c b/gcc/testsuite/gcc.dg/analyzer/pr99269.c
new file mode 100644
index 00000000000..1cce3aef8dd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr99269.c
@@ -0,0 +1,16 @@
+#include <stdlib.h>
+
+void example(void) {
+	int len;
+	int **namelist = NULL;
+
+	len = 2;
+	namelist = malloc(len * sizeof *namelist);
+	if (!namelist) return;
+	namelist[0] = malloc(sizeof **namelist);
+	namelist[1] = malloc(sizeof **namelist);
+
+	while(len--) { free(namelist[len]); }
+	free(namelist);
+	return;
+}
-- 
2.26.3



More information about the Gcc-patches mailing list