mirror of
https://github.com/json-c/json-c.git
synced 2026-03-24 07:29:07 +08:00
Fix Issue #111: Fix off-by-one error when range checking the input to json_tokener_error_desc().
This commit is contained in:
@@ -74,7 +74,7 @@ const char* json_tokener_errors[] = {
|
||||
const char *json_tokener_error_desc(enum json_tokener_error jerr)
|
||||
{
|
||||
int jerr_int = (int)jerr;
|
||||
if (jerr_int < 0 || jerr_int > (int)(sizeof(json_tokener_errors) / sizeof(json_tokener_errors[0])))
|
||||
if (jerr_int < 0 || jerr_int >= (int)(sizeof(json_tokener_errors) / sizeof(json_tokener_errors[0])))
|
||||
return "Unknown error, invalid json_tokener_error value passed to json_tokener_error_desc()";
|
||||
return json_tokener_errors[jerr];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user