From cc479321c387a8684248bf7dde969535f9ebcfad Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Mon, 30 Jan 2017 23:18:51 -0500 Subject: Have tvb_format_text use wmem_packet_scope() memory. It's only use is in dissectors or other tree creation APIs (where packet scope is valid), so have it use format_text_wmem with wmem_packet_scope(). Change-Id: I1f34e284a870c9844c6b27f4ae08a1e7efe54098 Reviewed-on: https://code.wireshark.org/review/19883 Reviewed-by: Michael Mann Petri-Dish: Michael Mann Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/tvbuff.c | 7 ++++--- epan/tvbuff.h | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 725fdffa53..c5050f32d5 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -2171,8 +2171,9 @@ tvb_memeql(tvbuff_t *tvb, const gint offset, const guint8 *str, size_t size) } } -/* - * Format the data in the tvb from offset for length ... +/** + * Format the data in the tvb from offset for size. Returned string is + * wmem packet_scoped so call must be in that scope. */ gchar * tvb_format_text(tvbuff_t *tvb, const gint offset, const gint size) @@ -2183,7 +2184,7 @@ tvb_format_text(tvbuff_t *tvb, const gint offset, const gint size) len = (size > 0) ? size : 0; ptr = ensure_contiguous(tvb, offset, size); - return format_text(ptr, len); + return format_text_wmem(wmem_packet_scope(), ptr, len); } /* diff --git a/epan/tvbuff.h b/epan/tvbuff.h index 95cf6cc17b..e5835516fd 100644 --- a/epan/tvbuff.h +++ b/epan/tvbuff.h @@ -536,7 +536,8 @@ WS_DLL_PUBLIC gint tvb_strnlen(tvbuff_t *tvb, const gint offset, const guint maxlength); /** - * Format the data in the tvb from offset for size ... + * Format the data in the tvb from offset for size. Returned string is + * wmem packet_scoped so call must be in that scope. */ WS_DLL_PUBLIC gchar *tvb_format_text(tvbuff_t *tvb, const gint offset, const gint size); -- cgit v1.2.3