aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2016-07-26 13:58:55 +0200
committerPascal Quantin <pascal.quantin@gmail.com>2016-07-26 13:48:40 +0000
commit4713ce4476cadb2d4a8869dd2e6f19547841aa9a (patch)
tree49eb6200d40c11472aa3283236b3ad38ba0c2b45 /ui
parent3a3bf8926eaa57bbe3941cbb0fb5d30ad92ede11 (diff)
Ensure to have a valid string pointer when writing OS SHB option
Change-Id: Ib0b6dcdf1700e88383d30bf43739312fce10e1c7 Reviewed-on: https://code.wireshark.org/review/16696 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk/file_import_dlg.c7
-rw-r--r--ui/tap_export_pdu.c7
2 files changed, 12 insertions, 2 deletions
diff --git a/ui/gtk/file_import_dlg.c b/ui/gtk/file_import_dlg.c
index dc6a97a4f5..09e319126a 100644
--- a/ui/gtk/file_import_dlg.c
+++ b/ui/gtk/file_import_dlg.c
@@ -465,6 +465,7 @@ file_import_open(text_import_info_t *info)
wtapng_if_descr_mandatory_t *int_data_mand;
GString *os_info_str;
gsize opt_len;
+ gchar *opt_str;
/* Create data for SHB */
os_info_str = g_string_new("");
@@ -480,7 +481,11 @@ file_import_open(text_import_info_t *info)
* this section.
*/
opt_len = os_info_str->len;
- wtap_block_add_string_option(shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, TRUE), opt_len);
+ opt_str = g_string_free(os_info_str, FALSE);
+ if (opt_str) {
+ wtap_block_add_string_option(shb_hdr, OPT_SHB_OS, opt_str, opt_len);
+ g_free(opt_str);
+ }
/*
* UTF-8 string containing the name of the application used to create
* this section.
diff --git a/ui/tap_export_pdu.c b/ui/tap_export_pdu.c
index 02cd3df33f..fec86cff1d 100644
--- a/ui/tap_export_pdu.c
+++ b/ui/tap_export_pdu.c
@@ -109,6 +109,7 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
wtapng_if_descr_mandatory_t *int_data_mand;
GString *os_info_str;
gsize opt_len;
+ gchar *opt_str;
/* Create data for SHB */
os_info_str = g_string_new("");
@@ -125,7 +126,11 @@ exp_pdu_open(exp_pdu_t *exp_pdu_tap_data, int fd, char *comment)
* this section.
*/
opt_len = os_info_str->len;
- wtap_block_add_string_option(shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, TRUE), opt_len);
+ opt_str = g_string_free(os_info_str, FALSE);
+ if (opt_str) {
+ wtap_block_add_string_option(shb_hdr, OPT_SHB_OS, opt_str, opt_len);
+ g_free(opt_str);
+ }
/*
* UTF-8 string containing the name of the application used to create
* this section.