diff --git a/file.c b/file.c index 414effde90..a65657a172 100644 --- a/file.c +++ b/file.c @@ -3962,7 +3962,8 @@ cf_get_packet_comment(capture_file *cf, const frame_data *fd) if (!cf_read_record_r(cf, fd, &rec, &buf)) { /* XXX, what we can do here? */ } - comment = rec.opt_comment; + /* rec.opt_comment is owned by the record, copy it before it is gone. */ + comment = g_strdup(rec.opt_comment); wtap_rec_cleanup(&rec); ws_buffer_free(&buf); return comment; diff --git a/file.h b/file.h index 2e0d78704b..0d9bcb318e 100644 --- a/file.h +++ b/file.h @@ -686,6 +686,7 @@ void cf_update_section_comment(capture_file *cf, gchar *comment); * * @param cf the capture file * @param fd the frame_data structure for the frame + * @returns A comment (use g_free to free) or NULL if there is none. */ char *cf_get_packet_comment(capture_file *cf, const frame_data *fd); diff --git a/ui/qt/capture_file_properties_dialog.cpp b/ui/qt/capture_file_properties_dialog.cpp index 270beb7e8e..bf0fb9d10a 100644 --- a/ui/qt/capture_file_properties_dialog.cpp +++ b/ui/qt/capture_file_properties_dialog.cpp @@ -542,7 +542,7 @@ void CaptureFilePropertiesDialog::fillDetails() if (pkt_comment) { QString frame_comment_html = tr("
Frame %1: ").arg(framenum);
- QString raw_comment = pkt_comment;
+ QString raw_comment = gchar_free_to_qstring(pkt_comment);
frame_comment_html += html_escape(raw_comment).replace('\n', "
");
frame_comment_html += "