Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for NULL inputs in ucl_object_compare() #207

Merged
merged 1 commit into from
Apr 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Check for NULL inputs in ucl_object_compare()
  • Loading branch information
Mike Owens committed May 8, 2019
commit 9208ef854c81e9ceb9617b249e3629be9d17082d
9 changes: 8 additions & 1 deletion src/ucl_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3649,6 +3649,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 Expand Up @@ -3912,4 +3919,4 @@ const char *
ucl_parser_get_cur_file (struct ucl_parser *parser)
{
return parser->cur_file;
}
}