diff options
author | Dario Lombardo <lomato@gmail.com> | 2019-01-12 22:58:28 +0100 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2019-01-12 23:39:54 +0000 |
commit | 48a00fd55671db5ac16bd4037ac9faffab94814c (patch) | |
tree | 30000fdc3eb95c8b0a9ccfce1f069972e126a25a /epan/ftypes | |
parent | 5ed8360c21ccc5c26ca47eb59b175634415ae11f (diff) |
ftype: rework val_from_unparsed to avoid double free.
Found by scan-build.
Change-Id: I07e8bf2099e08f3f544dd846572717044aa95f7c
Reviewed-on: https://code.wireshark.org/review/31487
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'epan/ftypes')
-rw-r--r-- | epan/ftypes/ftype-string.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/epan/ftypes/ftype-string.c b/epan/ftypes/ftype-string.c index 57d7d82352..97cf811dfe 100644 --- a/epan/ftypes/ftype-string.c +++ b/epan/ftypes/ftype-string.c @@ -90,12 +90,12 @@ val_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_, { fvalue_t *fv_bytes; - /* Free up the old value, if we have one */ - string_fvalue_free(fv); - /* Does this look like a byte-string? */ fv_bytes = fvalue_from_unparsed(FT_BYTES, s, TRUE, NULL); if (fv_bytes) { + /* Free up the old value, if we have one */ + string_fvalue_free(fv); + /* Copy the bytes over to a string and terminate it * with a NUL. XXX - what if the user embeds a NUL * in the middle of the byte string? */ @@ -107,10 +107,10 @@ val_from_unparsed(fvalue_t *fv, const char *s, gboolean allow_partial_value _U_, FVALUE_FREE(fv_bytes); return TRUE; + } else { + /* Just turn it into a string */ + return val_from_string(fv, s, err_msg); } - - /* Just turn it into a string */ - return val_from_string(fv, s, err_msg); } static guint |