diff options
Diffstat (limited to 'asn1/snmp/packet-snmp-template.c')
-rw-r--r-- | asn1/snmp/packet-snmp-template.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/asn1/snmp/packet-snmp-template.c b/asn1/snmp/packet-snmp-template.c index ab329668e6..185ff0c7d1 100644 --- a/asn1/snmp/packet-snmp-template.c +++ b/asn1/snmp/packet-snmp-template.c @@ -595,16 +595,16 @@ format_var(struct variable_list *variable, subid_t *variable_oid, * XXX - check for "sprint_realloc_objid()" failure. */ - /* - * XXX - if we convert this to ep_alloc(), make sure the fourth - * argument to sprint_realloc_objid() is FALSE. - */ - buf_len = 256; - buf = malloc(buf_len); + buf_len = 1024; + buf = ep_alloc(buf_len); if (buf != NULL) { *buf = '\0'; out_len = 0; - sprint_realloc_value(&buf, &buf_len, &out_len, TRUE, + /* We pass an ep allocated block here, NOT a malloced block + * so we MUST NOT allow reallocation, hence the fourth + * parameter MUST be 0/FALSE + */ + sprint_realloc_value(&buf, &buf_len, &out_len, FALSE, variable_oid, variable_oid_length, variable); } return buf; @@ -847,7 +847,6 @@ snmp_variable_decode(tvbuff_t *tvb, proto_tree *snmp_tree, packet_info *pinfo,tv proto_tree_add_text(snmp_tree, tvb, vb_value_start, length, "Value: %s", vb_display_string); - free(vb_display_string); } else { proto_tree_add_text(snmp_tree,tvb, vb_value_start, length, @@ -876,7 +875,6 @@ snmp_variable_decode(tvbuff_t *tvb, proto_tree *snmp_tree, packet_info *pinfo,tv proto_tree_add_text(snmp_tree, tvb, vb_value_start, length, "Value: %s", vb_display_string); - free(vb_display_string); } else { proto_tree_add_text(snmp_tree, tvb, vb_value_start, length, @@ -910,7 +908,6 @@ snmp_variable_decode(tvbuff_t *tvb, proto_tree *snmp_tree, packet_info *pinfo,tv proto_tree_add_text(snmp_tree, tvb, vb_value_start, length, "Value: %s", vb_display_string); - free(vb_display_string); } else { /* * If some characters are not printable, @@ -978,7 +975,6 @@ snmp_variable_decode(tvbuff_t *tvb, proto_tree *snmp_tree, packet_info *pinfo,tv proto_tree_add_text(snmp_tree, tvb, vb_value_start, length, "Value: %s", vb_display_string); - free(vb_display_string); } else { proto_tree_add_text(snmp_tree, tvb, vb_value_start, length, |