From: Matthew Fernandez Date: Sun, 14 Jun 2020 21:22:18 +0000 (-0700) Subject: deallocate memory before exiting mkdefs.c X-Git-Tag: 2.44.1~11^2~3^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7d9cfa8c3dddcaeb9a70d4e53d84d4374d60656b;p=graphviz 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. --- 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); }