From 2275e0273091314b38ed411a8cae39ed877f5bec Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 11 May 2016 04:22:20 +0000 Subject: [PATCH] Revert "Simplify val_to_str[_ext] implementation." This reverts commit 1d0a97493280fd79d00e85a0971b3842d7f00e5e. This appears to be causing a crash - and the code in val_to_str() isn't just a copy of the code in val_to_str_wmem(), as it doesn't do a wmem allocation if try_val_to_str(), which *doesn't* use wmem, succeeds. Change-Id: I40e9e8b4ed0a1c66e20ab4bd827ac51c3fac85ff Reviewed-on: https://code.wireshark.org/review/15351 Reviewed-by: Guy Harris --- epan/value_string.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/epan/value_string.c b/epan/value_string.c index aac00ba9ec..298fd176ed 100644 --- a/epan/value_string.c +++ b/epan/value_string.c @@ -38,7 +38,15 @@ const gchar * val_to_str(const guint32 val, const value_string *vs, const char *fmt) { - return val_to_str_wmem(wmem_packet_scope(), val, vs, fmt); + const gchar *ret; + + DISSECTOR_ASSERT(fmt != NULL); + + ret = try_val_to_str(val, vs); + if (ret != NULL) + return ret; + + return wmem_strdup_printf(wmem_packet_scope(), fmt, val); } gchar * @@ -309,7 +317,15 @@ try_val_to_str_idx_ext(const guint32 val, value_string_ext *vse, gint *idx) const gchar * val_to_str_ext(const guint32 val, value_string_ext *vse, const char *fmt) { - return val_to_str_ext_wmem(wmem_packet_scope(), val, vse, fmt); + const gchar *ret; + + DISSECTOR_ASSERT(fmt != NULL); + + ret = try_val_to_str_ext(val, vse); + if (ret != NULL) + return ret; + + return wmem_strdup_printf(wmem_packet_scope(), fmt, val); } gchar *