diff options
author | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2006-07-04 02:36:18 +0000 |
---|---|---|
committer | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2006-07-04 02:36:18 +0000 |
commit | 889fe1c6fe38d0ce2e7dde80843c79e033ac8393 (patch) | |
tree | 48a9270b991092e3770f6f920d280d1a27a52862 /asn1 | |
parent | 5e3fe341705e3d4ea6592f6cb8807461ae186409 (diff) |
make new_format_oid return ep allocated data.
this also removes several small memory leaks through get_oid_name and get_oid_str_name where the callers nevber freed the data
svn path=/trunk/; revision=18647
Diffstat (limited to 'asn1')
-rw-r--r-- | asn1/snmp/packet-snmp-template.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/asn1/snmp/packet-snmp-template.c b/asn1/snmp/packet-snmp-template.c index 064f4152f5..54020be7f1 100644 --- a/asn1/snmp/packet-snmp-template.c +++ b/asn1/snmp/packet-snmp-template.c @@ -439,8 +439,7 @@ format_oid(subid_t *oid, guint oid_length) return result; } -/* returns the decoded (can be NULL) and non_decoded OID strings, - returned pointers shall be freed by the caller */ +/* returns the decoded (can be NULL) and non_decoded OID strings */ void new_format_oid(subid_t *oid, guint oid_length, gchar **non_decoded, gchar **decoded) @@ -465,12 +464,16 @@ new_format_oid(subid_t *oid, guint oid_length, * argument to sprint_realloc_objid() is FALSE. */ - oid_string_len = 256; - oid_string = malloc(oid_string_len); + oid_string_len = 1024; + oid_string = ep_alloc(oid_string_len); if (oid_string != NULL) { *oid_string = '\0'; oid_out_len = 0; - sprint_realloc_objid(&oid_string, &oid_string_len, &oid_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_objid(&oid_string, &oid_string_len, &oid_out_len, FALSE, oid, oid_length); } *decoded = oid_string; |