diff --git a/json_tokener.c b/json_tokener.c index 773229e..1954bcd 100644 --- a/json_tokener.c +++ b/json_tokener.c @@ -154,6 +154,9 @@ struct json_tokener *json_tokener_new_ex(int depth) { struct json_tokener *tok; + if (depth < 1) + return NULL; + tok = (struct json_tokener *)calloc(1, sizeof(struct json_tokener)); if (!tok) return NULL; diff --git a/json_tokener.h b/json_tokener.h index 54925e5..f53a761 100644 --- a/json_tokener.h +++ b/json_tokener.h @@ -206,6 +206,7 @@ JSON_EXPORT struct json_tokener *json_tokener_new(void); /** * Allocate a new json_tokener with a custom max nesting depth. + * The depth must be at least 1. * @see JSON_TOKENER_DEFAULT_DEPTH */ JSON_EXPORT struct json_tokener *json_tokener_new_ex(int depth);