duplocale() can return NULL, with errno set to ENOMEM. In this case, bail out and set the current error code to json_tokener_error_memory.