analyzer: add regression test [PR99269]
authorDavid Malcolm <dmalcolm@redhat.com>
Tue, 30 Nov 2021 19:47:24 +0000 (14:47 -0500)
committerDavid Malcolm <dmalcolm@redhat.com>
Tue, 30 Nov 2021 22:49:05 +0000 (17:49 -0500)
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 [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/analyzer/pr99269.c b/gcc/testsuite/gcc.dg/analyzer/pr99269.c
new file mode 100644 (file)
index 0000000..1cce3ae
--- /dev/null
@@ -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;
+}