get_datafile_path() and get_persconffile_path() return malloc'd memory,
authormorriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 26 Feb 2008 19:13:43 +0000 (19:13 +0000)
committermorriss <morriss@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 26 Feb 2008 19:13:43 +0000 (19:13 +0000)
free it when we're done with the file name.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@24478 f5534014-38df-0310-8fa8-9805f1628bb7

color_filters.c
filters.c

index 652dcb19a6c385c1b8280bc4d1c22ad5f12d54a4..4d45c08ea52dea24698e6f57f47fe8fbd3198629 100644 (file)
@@ -759,8 +759,10 @@ color_filters_write(GSList *cfl)
                simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
                    "Could not open\n%s\nfor writing: %s.",
                    path, strerror(errno));
+               g_free(path);
                return FALSE;
        }
+       g_free(path);
        write_filters_file(cfl, f, FALSE);
        fclose(f);
        return TRUE;
index 71d177135b6efec77570cb0b35602c5b1de7049a..c13947ffe6565da00fd0536001822de70d37433a 100644 (file)
--- a/filters.c
+++ b/filters.c
@@ -170,33 +170,36 @@ read_filter_list(filter_list_type_t list_type, char **pref_path_return,
     g_free(ff_path);
     ff_path = get_persconffile_path(FILTER_FILE_NAME, FALSE, FALSE);
     if ((ff = eth_fopen(ff_path, "r")) == NULL) {
-    /*
-     * Did that fail because the file didn't exist?
-     */
-      if (errno != ENOENT) {
       /*
-       * No.  Just give up.
+       * Did that fail because the file didn't exist?
        */
-       *pref_path_return = ff_path;
-       *errno_return = errno;
-    return;
-      }
-
-    /*
-     * Try to open the global "cfilters/dfilters" file */
-    ff_path = get_datafile_path(ff_name);
-    if ((ff = eth_fopen(ff_path, "r")) == NULL) {
+       if (errno != ENOENT) {
+       /*
+        * No.  Just give up.
+        */
+         *pref_path_return = ff_path;
+         *errno_return = errno;
+         return;
+       }
 
       /*
-       * Well, that didn't work, either.  Just give up.
-       * Return an error if the file existed but we couldn't open it.
-       */
-      if (errno != ENOENT) {
-       *pref_path_return = ff_path;
-       *errno_return = errno;
-    }
-    return;
-    }
+       * Try to open the global "cfilters/dfilters" file */
+      g_free(ff_path);
+      ff_path = get_datafile_path(ff_name);
+      if ((ff = eth_fopen(ff_path, "r")) == NULL) {
+
+       /*
+        * Well, that didn't work, either.  Just give up.
+        * Return an error if the file existed but we couldn't open it.
+        */
+       if (errno != ENOENT) {
+         *pref_path_return = ff_path;
+         *errno_return = errno;
+       } else {
+         g_free(ff_path);
+       }
+       return;
+      }
     }
   }