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

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

epan/uat.c
epan/uat_load.l

index e94bb2d9bd222bb8b1abe176d147a2b0e62361de..cf891685ae131a0dae6a57141fe119a54190adc1 100644 (file)
@@ -154,18 +154,24 @@ void uat_remove_record_idx(uat_t* uat, guint idx) {
 
 }
 
+/* The returned filename was g_malloc()'d so the caller must free it */
 gchar* uat_get_actual_filename(uat_t* uat, gboolean for_writing) {
+
        gchar* pers_fname =  get_persconffile_path(uat->filename, TRUE, for_writing);
 
        if (! for_writing ) {
                gchar* data_fname = get_datafile_path(uat->filename);
 
                if ((! file_exists(pers_fname) ) && file_exists(data_fname)) {
+                       g_free(pers_fname);
                        return data_fname;
                }
+
+               g_free(data_fname);
        }
 
        if ((! file_exists(pers_fname) ) && (! for_writing ) ) {
+               g_free(pers_fname);
                return NULL;
        }
 
index 42593998d98562cc989fb26be277ba190e89ad68..ec93d11100ea3d26b0eaf9bb8af082c585a5467b 100644 (file)
@@ -289,6 +289,7 @@ gboolean uat_load(uat_t* uat_in, char** err) {
 
        if (!(yyin = eth_fopen(fname,"r"))) {
                *err = strerror(errno);
+               g_free(fname);
                return FALSE;
        }
 
@@ -299,6 +300,7 @@ gboolean uat_load(uat_t* uat_in, char** err) {
 
        BEGIN START_OF_LINE;
        DUMP(fname);
+       g_free(fname);  /* we're done with the file name now */
 
        yylex();
        yyrestart(NULL);