diff options
author | Guy Harris <guy@alum.mit.edu> | 2003-10-29 23:48:14 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2003-10-29 23:48:14 +0000 |
commit | 0c0ef440950eae87c78ef3c1435f109c1c60266a (patch) | |
tree | 469cfaa59b29de3f6b3bf36caf41672f2dfff2aa /epan/ftypes/ftype-bytes.c | |
parent | b4bdaa5e9f2d60ce962f13cc7bf94348850c060d (diff) |
Make the "fvalue_set" methods for types whose value is allocated free
any previously-allocated version first, so that they don't leak memory.
From Olivier Biot: add a "proto_item_append_string()" routine, to append
to the string value a protocol tree item has.
svn path=/trunk/; revision=8821
Diffstat (limited to 'epan/ftypes/ftype-bytes.c')
-rw-r--r-- | epan/ftypes/ftype-bytes.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/epan/ftypes/ftype-bytes.c b/epan/ftypes/ftype-bytes.c index e0e859fab7..84c9f58a64 100644 --- a/epan/ftypes/ftype-bytes.c +++ b/epan/ftypes/ftype-bytes.c @@ -1,5 +1,5 @@ /* - * $Id: ftype-bytes.c,v 1.17 2003/08/27 15:23:05 gram Exp $ + * $Id: ftype-bytes.c,v 1.18 2003/10/29 23:48:14 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -55,6 +55,10 @@ static void bytes_fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied) { g_assert(already_copied); + + /* Free up the old value, if we have one */ + bytes_fvalue_free(fv); + fv->value.bytes = value; } @@ -92,6 +96,9 @@ bytes_to_repr(fvalue_t *fv, ftrepr_t rtype _U_, char *buf) static void common_fvalue_set(fvalue_t *fv, guint8* data, guint len) { + /* Free up the old value, if we have one */ + bytes_fvalue_free(fv); + fv->value.bytes = g_byte_array_new(); g_byte_array_append(fv->value.bytes, data, len); } @@ -220,8 +227,10 @@ bytes_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, Log return FALSE; } - fv->value.bytes = bytes; + /* Free up the old value, if we have one */ + bytes_fvalue_free(fv); + fv->value.bytes = bytes; return TRUE; } |