Skip to content

Commit c975045

Browse files
author
Mandeep Singh Grang
committed
[BugFix] Pointer arithmetic on null pointer
Pointer arithmetic was done before checking for null. This bug is uncovered by inserting dynamic null ptr checks in checkedc/checkedc-clang#663.
1 parent d27517f commit c975045

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

parson.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1950,13 +1950,13 @@ JSON_Status json_object_dotset_value(JSON_Object *object : itype(_Ptr<JSON_Objec
19501950
return JSONFailure;
19511951
}
19521952
dot_pos = (_Nt_array_ptr<const char>)strchr(name, '.');
1953+
if (dot_pos == NULL) {
1954+
return json_object_set_value(object, name, value);
1955+
}
19531956
_Nt_array_ptr<const char> after_dot = NULL;
19541957
_Unchecked {
19551958
after_dot = _Assume_bounds_cast<_Nt_array_ptr<const char>>(dot_pos + 1, count(0));
19561959
}
1957-
if (dot_pos == NULL) {
1958-
return json_object_set_value(object, name, value);
1959-
}
19601960
name_len = dot_pos - name;
19611961
_Nt_array_ptr<const char> name_with_len : count(name_len) = NULL;
19621962
_Unchecked {

0 commit comments

Comments
 (0)