diff options
author | Michael Mann <mmann78@netscape.net> | 2016-07-31 09:54:32 -0400 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2016-07-31 15:30:27 +0000 |
commit | 078ba235aff3cf7d8622c657ee308098c81086ac (patch) | |
tree | 2bddcf9590de904b5322190df846974c7d105612 /epan/oids.c | |
parent | 7855160bab3200fcf76413972f7a816a8d92fc3d (diff) |
oids.c: Use wmem_strbuf instead of trying to accommodate snprintf.
Change-Id: I5222fbd07b7d1301386f7a206fef688793dd6be7
Reviewed-on: https://code.wireshark.org/review/16802
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/oids.c')
-rw-r--r-- | epan/oids.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/epan/oids.c b/epan/oids.c index 5230c37c8b..66a9c12a45 100644 --- a/epan/oids.c +++ b/epan/oids.c @@ -860,33 +860,22 @@ char* oid_subid2string(wmem_allocator_t *scope, guint32* subids, guint len) { return rel_oid_subid2string(scope, subids, len, TRUE); } char* rel_oid_subid2string(wmem_allocator_t *scope, guint32* subids, guint len, gboolean is_absolute) { - char *s, *w; + + wmem_strbuf_t *oid_str; if(!subids || len == 0) return wmem_strdup(scope, "*** Empty OID ***"); - s = (char *)wmem_alloc0(scope, ((len)*11)+2); - w = s; + oid_str = wmem_strbuf_new(scope, ""); if (!is_absolute) - *w++ = '.'; + wmem_strbuf_append_c(oid_str, '.'); do { -#ifdef _WIN32 - /* - * GLib appears to use gnulib's snprintf on Windows, which is - * slow. MSDN says that _snprintf can return -1, but that - * shouldn't be possible here. - */ - w += _snprintf(w,12,"%u.",*subids++); -#else - w += g_snprintf(w,12,"%u.",*subids++); -#endif + wmem_strbuf_append_printf(oid_str, "%u.",*subids++); } while(--len); - if (w!=s) *(w-1) = '\0'; else *(s) = '\0'; - - return s; + return wmem_strbuf_finalize(oid_str); } static guint check_num_oid(const char* str) { |