]> granicus.if.org Git - graphviz/commitdiff
deallocate memory before exiting mkdefs.c
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 14 Jun 2020 21:22:18 +0000 (14:22 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 14 Jun 2020 21:22:18 +0000 (14:22 -0700)
The code in mkdef.c gets compiled and executed during Graphviz compilation. When
building with Address Sanitizer enabled, instrumentation is also applied to this
utility during compilation. Usually this is not a problem, but when configuring
ASan to exit with an error on leak detection it would cause the build step that
runs mkdefs to erroneously fail. We now explicitly clean up before exiting
mkdefs, making ASan happy in all configurations. Closes #1741.

lib/gvpr/mkdefs.c

index b1d9b7041af5a3a6ba60f540feb8b83532d55b21..0b1993f5b9b01025038bfecd268a2ef2ba2479bc 100644 (file)
@@ -202,5 +202,14 @@ int main(int argc, char *argv[])
 
     fprintf(fp, "\n#endif\n");
     fclose(fp);
+
+    /* clean up */
+    for (recp = vals.next; recp; recp = vals.next) {
+      free(recp->data);
+      vals.next = recp->next;
+      free(recp);
+    }
+    free(buf);
+
     exit(0);
 }