summaryrefslogtreecommitdiff
path: root/wiretap/merge.c
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 /wiretap/merge.c
parent3a3bf8926eaa57bbe3941cbb0fb5d30ad92ede11 (diff)
downloadwireshark-4713ce4476cadb2d4a8869dd2e6f19547841aa9a.tar.gz
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 'wiretap/merge.c')
-rw-r--r--wiretap/merge.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/wiretap/merge.c b/wiretap/merge.c
index 89887ffee6..4c14b1efaf 100644
--- a/wiretap/merge.c
+++ b/wiretap/merge.c
@@ -372,6 +372,7 @@ create_shb_header(const merge_in_file_t *in_files, const guint in_file_count,
char* shb_comment = NULL;
wtapng_mandatory_section_t* shb_data;
gsize opt_len;
+ gchar *opt_str;
shb_hdrs = wtap_file_get_shb_for_new_file(in_files[0].wth);
shb_hdr = g_array_index(shb_hdrs, wtap_block_t, 0);
@@ -412,8 +413,12 @@ create_shb_header(const merge_in_file_t *in_files, const guint in_file_count,
*/
wtap_block_remove_option(shb_hdr, OPT_SHB_HARDWARE);
opt_len = os_info_str->len;
- wtap_block_set_string_option_value(shb_hdr, OPT_SHB_OS, g_string_free(os_info_str, FALSE), opt_len); /* UTF-8 string containing the name */
- /* of the operating system used to create this section. */
+ opt_str = g_string_free(os_info_str, FALSE);
+ if (opt_str) {
+ wtap_block_set_string_option_value(shb_hdr, OPT_SHB_OS, opt_str, opt_len); /* UTF-8 string containing the name */
+ /* of the operating system used to create this section. */
+ g_free(opt_str);
+ }
wtap_block_set_string_option_value(shb_hdr, OPT_SHB_USERAPPL, (char*)app_name, app_name ? strlen(app_name): 0 ); /* NULL if not available, UTF-8 string containing the name */
/* of the application used to create this section. */