Do *NOT* assume col_get_text(cinfo, el) never returns NULL!

It can, and, in at least one capture, it does.

Change-Id: Id3540e6551db5d63427f09c6ccc521958ecccac6
Reviewed-on: https://code.wireshark.org/review/33231
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2019-05-16 11:48:15 -07:00
parent 576f33fffd
commit 1942fa9e5a
1 changed files with 6 additions and 2 deletions

View File

@ -3887,7 +3887,9 @@ Only set a valued with col_set_str() if it does not yet exist.
*/
void col_set_str_conditional(column_info *cinfo, const gint el, const gchar* str)
{
if (!g_str_has_prefix(col_get_text(cinfo, el), str))
const char *col_string = col_get_text(cinfo, el);
if (col_string == NULL || !g_str_has_prefix(col_string, str))
{
col_add_str(cinfo, el, str);
}
@ -3898,7 +3900,9 @@ CSV add a value to a column, if it does not exist yet
*/
void col_append_str_conditional(column_info *cinfo, const gint el, const gchar* str)
{
if (!g_strrstr(col_get_text(cinfo, el), str))
const char *col_string = col_get_text(cinfo, el);
if (col_string == NULL || !g_strrstr(col_string, str))
{
col_append_fstr(cinfo, el, ", %s", str);
}