From 7d9cfa8c3dddcaeb9a70d4e53d84d4374d60656b Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 14 Jun 2020 14:22:18 -0700 Subject: [PATCH] deallocate memory before exiting mkdefs.c 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/gvpr/mkdefs.c b/lib/gvpr/mkdefs.c index b1d9b7041..0b1993f5b 100644 --- a/lib/gvpr/mkdefs.c +++ b/lib/gvpr/mkdefs.c @@ -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); } -- 2.40.0