diff --git a/arraylist.c b/arraylist.c index 88c6d23..f1b73b0 100644 --- a/arraylist.c +++ b/arraylist.c @@ -83,7 +83,10 @@ static int array_list_expand_internal(struct array_list *arr, size_t max) void *t; size_t new_size; - if (max < arr->size) + /* The array can already hold max entries when max == arr->size, since + * the caller only ever indexes up to max - 1. + */ + if (max <= arr->size) return 0; /* Avoid undefined behaviour on size_t overflow */ if (arr->size >= SIZE_T_MAX / 2) diff --git a/json_tokener.c b/json_tokener.c index cfa01ab..516142a 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -1157,7 +1157,7 @@ struct json_object *json_tokener_parse_ex(struct json_tokener *tok, const char * } if (numuint64 <= INT64_MAX) { - num64 = (uint64_t)numuint64; + num64 = (int64_t)numuint64; current = json_object_new_int64(num64); if (current == NULL) {