summaryrefslogtreecommitdiff
path: root/epan/proto.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-05-10 09:06:18 -0400
committerMichael Mann <mmann78@netscape.net>2016-05-10 20:39:45 +0000
commit37ee33c9b2e184089c55d96d65be5996f3b338b6 (patch)
tree80102c90cb921cb394927f888d99e5157a1ec57f /epan/proto.c
parentfb7cd193ab5d2a2f88b017134c1446099900f318 (diff)
downloadwireshark-37ee33c9b2e184089c55d96d65be5996f3b338b6.tar.gz
Dynamically allocate the string for representing FT_IEEE_11073_[S]FLOAT.
Most uses of fvalue_to_string_repr() don't provide a buffer to write to, so memory is allocated dynamically inside the function. Trying to move to where ALL cases don't provide a buffer to simplify fvalue_to_string_repr handling and the underlying functionality of the ftypes. Change-Id: Iac03e4eb63b5e38311a6472fbe488009ed55206c Reviewed-on: https://code.wireshark.org/review/15331 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/proto.c')
-rw-r--r--epan/proto.c53
1 files changed, 22 insertions, 31 deletions
diff --git a/epan/proto.c b/epan/proto.c
index 91ce7a4cb0..c41b28239e 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -5232,25 +5232,21 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
break;
case FT_IEEE_11073_SFLOAT:
- {
- guint8 buf[240];
- fvalue_to_string_repr(&finfo->value, FTREPR_DISPLAY, hfinfo->display, buf);
- g_snprintf(result+offset_r, size-offset_r,
+ str = fvalue_to_string_repr(&finfo->value, FTREPR_DISPLAY, hfinfo->display, NULL);
+ g_snprintf(result+offset_r, size-offset_r,
"%s: %s",
- hfinfo->name, buf);
- }
+ hfinfo->name, str);
+ g_free(str);
offset_r = (int)strlen(result);
break;
case FT_IEEE_11073_FLOAT:
- {
- guint8 buf[240];
- fvalue_to_string_repr(&finfo->value, FTREPR_DISPLAY, hfinfo->display, buf);
- g_snprintf(result+offset_r, size-offset_r,
+ str = fvalue_to_string_repr(&finfo->value, FTREPR_DISPLAY, hfinfo->display, NULL);
+ g_snprintf(result+offset_r, size-offset_r,
"%s: %s",
- hfinfo->name, buf);
- }
+ hfinfo->name, str);
offset_r = (int)strlen(result);
+ g_free(str);
break;
case FT_IPXNET: /*XXX really No column custom ?*/
@@ -7321,22 +7317,18 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
break;
case FT_IEEE_11073_SFLOAT:
- {
- guint8 buf[240];
- fvalue_to_string_repr(&fi->value, FTREPR_DISPLAY, hfinfo->display, buf);
- g_snprintf(label_str, ITEM_LABEL_LENGTH,
- "%s: %s",
- hfinfo->name, buf);
- }
+ tmp = fvalue_to_string_repr(&fi->value, FTREPR_DISPLAY, hfinfo->display, NULL);
+ g_snprintf(label_str, ITEM_LABEL_LENGTH,
+ "%s: %s",
+ hfinfo->name, tmp);
+ g_free(tmp);
break;
case FT_IEEE_11073_FLOAT:
- {
- guint8 buf[240];
- fvalue_to_string_repr(&fi->value, FTREPR_DISPLAY, hfinfo->display, buf);
- g_snprintf(label_str, ITEM_LABEL_LENGTH,
- "%s: %s",
- hfinfo->name, buf);
- }
+ tmp = fvalue_to_string_repr(&fi->value, FTREPR_DISPLAY, hfinfo->display, NULL);
+ g_snprintf(label_str, ITEM_LABEL_LENGTH,
+ "%s: %s",
+ hfinfo->name, tmp);
+ g_free(tmp);
break;
default:
@@ -8835,17 +8827,16 @@ construct_match_selected_string(field_info *finfo, epan_dissect_t *edt,
* 1 byte for trailing NUL.
*/
if (filter != NULL) {
+ char* str;
dfilter_len = fvalue_string_repr_len(&finfo->value,
FTREPR_DFILTER, finfo->hfinfo->display);
dfilter_len += abbrev_len + 4 + 1;
*filter = (char *)wmem_alloc0(NULL, dfilter_len);
/* Create the string */
- g_snprintf(*filter, dfilter_len, "%s == ",
- hfinfo->abbrev);
- fvalue_to_string_repr(&finfo->value,
- FTREPR_DFILTER, finfo->hfinfo->display,
- &(*filter)[abbrev_len + 4]);
+ str = fvalue_to_string_repr(&finfo->value, FTREPR_DFILTER, finfo->hfinfo->display, NULL);
+ g_snprintf(*filter, dfilter_len, "%s == %s", hfinfo->abbrev, str);
+ g_free(str);
}
break;
}