]> granicus.if.org Git - graphviz/commitdiff
fix memory leak due to config text
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 30 May 2020 02:10:19 +0000 (19:10 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 6 Jun 2020 00:35:25 +0000 (17:35 -0700)
We now no longer retain pointers to this variable internally, so we can
unconditionally free it. Fixes #1543.

lib/gvc/gvconfig.c

index aaae4f15dfa0db67c350fe1d80da735200da89d8..d2e3325b7feb9129cd69062a67a742f2b7c10151 100644 (file)
@@ -543,14 +543,13 @@ void gvconfig(GVC_t * gvc, boolean rescan)
                sz = fread(config_text, 1, config_st.st_size, f);
                if (sz == 0) {
                    agerr(AGERR,"%s is zero sized, or other read error.\n", gvc->config_path);
-                   free(config_text);
                }
                else {
                    gvc->config_found = TRUE;
                    config_text[sz] = '\0';  /* make input into a null terminated string */
                    rc = gvconfig_plugin_install_from_config(gvc, config_text);
-                   /* NB. config_text not freed because we retain char* into it */
                }
+               free(config_text);
            }
            if (f) {
                fclose(f);