stats_tree: plug a memory leak.

Don't allocate the GString until we know we'll be using it.

Change-Id: I97e2f897795ada864cbacc3822d39e7348a93ca2
Ping-Bug: 16335
Reviewed-on: https://code.wireshark.org/review/37048
Petri-Dish: Guy Harris <gharris@sonic.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <gharris@sonic.net>
This commit is contained in:
Guy Harris 2020-05-02 17:35:31 -07:00 committed by Guy Harris
parent b99dcf0593
commit c22b2ccd94
1 changed files with 2 additions and 1 deletions

View File

@ -1330,7 +1330,6 @@ add_string_fmt(string_fmt_e format, gchar *plain) {
static gboolean
parse_field_string_format(gchar *format) {
GString *plain_s = g_string_new("");
size_t len;
size_t pos = 0;
@ -1338,6 +1337,8 @@ parse_field_string_format(gchar *format) {
return FALSE;
}
GString *plain_s = g_string_new("");
len = strlen(format);
g_ptr_array_set_size(string_fmts, 0);