Revert "Simplify val_to_str[_ext] implementation."

This reverts commit 1d0a974932.

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 <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2016-05-11 04:22:20 +00:00
parent 1d0a974932
commit 2275e02730
1 changed files with 18 additions and 2 deletions

View File

@ -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 *