diff options
author | Guy Harris <gharris@sonic.net> | 2021-07-16 15:59:58 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-07-16 15:59:58 -0700 |
commit | c64a9bbde75ec9c098b6028d020266e1ea023d29 (patch) | |
tree | 77cf65abf967a313b4e10298afd7af178aca9e74 /wiretap | |
parent | 27c72d1edcc34339d8e120f98705106e82821d38 (diff) |
erf: make a copy of the first SHB comment.
We free it, but what wtap_block_get_nth_string_option_value() returns is
what's stored in the block, and it might get freed up out from under us.
Save a copy of it, so that when we free it, we're not double-freeing.
Diffstat (limited to 'wiretap')
-rw-r--r-- | wiretap/erf.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/wiretap/erf.c b/wiretap/erf.c index 9493b05818..d04bda82fb 100644 --- a/wiretap/erf.c +++ b/wiretap/erf.c @@ -2045,6 +2045,7 @@ static int erf_dump_open(wtap_dumper *wdh, int *err _U_, gchar **err_info _U_) erf_dump_t *dump_priv; gchar *s; guint64 host_id; + char *first_shb_comment; dump_priv = erf_dump_priv_create(); @@ -2052,8 +2053,10 @@ static int erf_dump_open(wtap_dumper *wdh, int *err _U_, gchar **err_info _U_) wdh->priv = dump_priv; wdh->subtype_finish = erf_dump_finish; - /* Get the capture comment string */ - get_user_comment_string(wdh, &dump_priv->user_comment_ptr); + /* Get the first capture comment string */ + get_user_comment_string(wdh, &first_shb_comment); + /* Save a copy of it */ + dump_priv->user_comment_ptr = g_strdup(first_shb_comment); /* XXX: If we have a capture comment or a non-ERF file assume we need to * write metadata unless we see existing metadata in the first second. */ if (dump_priv->user_comment_ptr || wdh->encap != WTAP_ENCAP_ERF) |