Revert "Simplify val_to_str[_ext] implementation."
authorGuy Harris <guy@alum.mit.edu>
Wed, 11 May 2016 04:22:20 +0000 (04:22 +0000)
committerGuy Harris <guy@alum.mit.edu>
Wed, 11 May 2016 04:22:26 +0000 (04:22 +0000)
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 <guy@alum.mit.edu>
epan/value_string.c

index aac00ba9ec1ff4c6826ce10c44b177746e68e400..298fd176ed34f5b9322726c3e732bbecaa8a7f55 100644 (file)
 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 *