Skip to content

Commit 7bc3dc8

Browse files
committed
Fix crash of cJSON_GetObjectItemCaseSensitive when calling it on arrays
1 parent b050ede commit 7bc3dc8

File tree

1 file changed

+5
-1
lines changed
  • hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/utils/cJSON

1 file changed

+5
-1
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/native/container-executor/impl/utils/cJSON/cJSON.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1781,7 +1781,7 @@ static cJSON *get_object_item(const cJSON * const object, const char * const nam
17811781
current_element = object->child;
17821782
if (case_sensitive)
17831783
{
1784-
while ((current_element != NULL) && (strcmp(name, current_element->string) != 0))
1784+
while ((current_element != NULL) && (current_element->string != NULL) && (strcmp(name, current_element->string) != 0))
17851785
{
17861786
current_element = current_element->next;
17871787
}
@@ -1794,6 +1794,10 @@ static cJSON *get_object_item(const cJSON * const object, const char * const nam
17941794
}
17951795
}
17961796

1797+
if ((current_element == NULL) || (current_element->string == NULL)) {
1798+
return NULL;
1799+
}
1800+
17971801
return current_element;
17981802
}
17991803

0 commit comments

Comments
 (0)