aboutsummaryrefslogtreecommitdiffstats
path: root/wiretap/lanalyzer.c
diff options
context:
space:
mode:
Diffstat (limited to 'wiretap/lanalyzer.c')
-rw-r--r--wiretap/lanalyzer.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/wiretap/lanalyzer.c b/wiretap/lanalyzer.c
index 72ebba82e3..eb4ad3815e 100644
--- a/wiretap/lanalyzer.c
+++ b/wiretap/lanalyzer.c
@@ -323,12 +323,15 @@ wtap_open_return_val lanalyzer_open(wtap *wth, int *err, gchar **err_info)
comment = (char *)g_malloc(record_length + 1);
if (!wtap_read_bytes(wth->fh, comment, record_length,
err, err_info)) {
- if (*err != WTAP_ERR_SHORT_READ)
- return WTAP_OPEN_ERROR;
+ if (*err != WTAP_ERR_SHORT_READ) {
+ g_free(comment);
+ return WTAP_OPEN_ERROR;
+ }
+ g_free(comment);
return WTAP_OPEN_NOT_MINE;
}
- comment[record_length] = '\0';
- wtap_optionblock_set_option_string(wth->shb_hdr, OPT_COMMENT, comment);
+ wtap_optionblock_set_option_string(wth->shb_hdr, OPT_COMMENT, comment, record_length);
+ g_free(comment);
}
/* If we made it this far, then the file is a LANAlyzer file.