Skip to content

Commit

Permalink
Merge pull request #207 from mikeowens/master
Browse files Browse the repository at this point in the history
Check for NULL inputs in ucl_object_compare()
  • Loading branch information
vstakhov committed Apr 4, 2020
2 parents 875c251 + 9208ef8 commit 2e528a2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ucl_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3664,6 +3664,13 @@ ucl_object_compare (const ucl_object_t *o1, const ucl_object_t *o2)
ucl_object_iter_t iter = NULL;
int ret = 0;

// Must check for NULL or code will segfault
if ((o1 == NULL) || (o2 == NULL))
{
// The only way this could be true is of both are NULL
return (o1 == NULL) && (o2 == NULL);
}

if (o1->type != o2->type) {
return (o1->type) - (o2->type);
}
Expand Down

0 comments on commit 2e528a2

Please sign in to comment.