diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-01-13 12:13:45 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-01-13 20:20:03 +0000 |
commit | bc23f797296582d5aca5029dd34244de41ff8605 (patch) | |
tree | c582e37dbe1f7186d2a8f16e8c6b22ab608b055d /epan/uat_load.l | |
parent | a988253fef15e6a0ddd05b0fb06e18ccde00082b (diff) |
UAT error string pointers should not be const pointers.
UAT error strings are usually allocated by g_strdup() or
g_strdup_printf(), and must ultimately be freed by the caller.
Make the pointer-to-error-string-pointer arguments to various functions
be "char **", not "const char **".
Fix cases that finds where a raw string was being used, as that won't
work if you try to free it; g_strdup() it instead.
Add a missing free of an error string.
Remove some no-longer-necessary casts.
Remove some unnecessary g_strdup()s (the string being handed to it was
already g_malloc()ated).
Change some variable declarations to match.
Put in XXX comments for some cases where the error string is just freed,
without being shown to the user.
Change-Id: I40297746a2ef729c56763baeddbb0842386fa0d0
Reviewed-on: https://code.wireshark.org/review/6525
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/uat_load.l')
-rw-r--r-- | epan/uat_load.l | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/epan/uat_load.l b/epan/uat_load.l index d23b0a3414..acd9895f26 100644 --- a/epan/uat_load.l +++ b/epan/uat_load.l @@ -86,10 +86,11 @@ static guint parse_str_pos; } while(0) #define SET_FIELD() \ - { const gchar* errx; \ + { gchar* errx; \ if (uat->fields[colnum].cb.chk) { \ if ( ! uat->fields[colnum].cb.chk(record, ptrx, len, uat->fields[colnum].cbdata.chk, uat->fields[colnum].fld_data, &errx) ) { \ error = g_strdup_printf("%s:%d: %s",uat->filename,linenum,errx); \ + g_free(errx); \ valid_record = FALSE; \ }\ }\ @@ -239,7 +240,7 @@ comment #[^\n]*\n <END_OF_RECORD>{newline} { void* rec; - const char* err = NULL; + char* err = NULL; linenum++; @@ -253,7 +254,7 @@ comment #[^\n]*\n uat->update_cb(rec,&err); if (err) { - error = (gchar*)err; + error = err; yyterminate(); } @@ -327,7 +328,7 @@ uat_load(uat_t *uat_in, char **errx) UAT_UPDATE(uat); if (error) { - *errx = g_strdup(error); + *errx = error; return FALSE; } @@ -366,7 +367,7 @@ uat_load_str(uat_t *uat_in, char *entry, char **err) UAT_UPDATE(uat); if (error) { - *err = g_strdup(error); + *err = error; return FALSE; } |