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>
This commit is contained in:
parent
fb7cd193ab
commit
37ee33c9b2
53
epan/proto.c
53
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue