The function vsnprintf returns a negative value on error, e.g. on
an invalid format. It's best to return NULL in such a case.
Also avoid a signed integer overflow if vsnprintf returns INT_MAX.
This is undefined behaviour in C and has to be avoided.
A negative value is returned with a call like:
json_sprintf("%111111111111111s", "", "");
INT_MAX is returned with a call like:
json_sprintf("%647s%2147483000s", "", "");