Skip to content

Commit

Permalink
Prevent g_strsplit to be called with NULL.
Browse files Browse the repository at this point in the history
There might be situations where ref_ids is NULL,
so return an error instead of handing it over to g_strsplit()
which will bail out via assert().
  • Loading branch information
janowagner authored and jjnicola committed Jun 7, 2019
1 parent ba5705b commit 3664ee8
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion base/nvti.c
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ nvti_set_category (nvti_t *n, const gint category)
*
* @param ref_text The optional text accompanying all references.
*
* @return 0 for success. 1 if n was NULL.
* @return 0 for success. 1 if n was NULL, 2 if ref_ids was NULL.
*/
int
nvti_add_refs (nvti_t *n, const gchar *type, const gchar *ref_ids,
Expand All @@ -968,6 +968,9 @@ nvti_add_refs (nvti_t *n, const gchar *type, const gchar *ref_ids,
if (!n)
return (1);

if (!ref_ids)
return (2);

split = g_strsplit (ref_ids, ",", 0);

for (item = split; *item; item++)
Expand Down

0 comments on commit 3664ee8

Please sign in to comment.