From 38249f5c21ed59c9688907c6d9e4c19670823843 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Wed, 15 Jan 2014 13:47:06 +0100 Subject: [PATCH] Fixed bugs in when token is not found --- JsonObjectBase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/JsonObjectBase.cpp b/JsonObjectBase.cpp index 1e158678..38a26326 100644 --- a/JsonObjectBase.cpp +++ b/JsonObjectBase.cpp @@ -39,21 +39,21 @@ bool JsonObjectBase::getBoolFromToken(jsmntok_t* token) double JsonObjectBase::getDoubleFromToken(jsmntok_t* token) { - if (token->type != JSMN_PRIMITIVE) return 0; + if (token == 0 || token->type != JSMN_PRIMITIVE) return 0; return strtod(json + token->start, 0); } long JsonObjectBase::getLongFromToken(jsmntok_t* token) { - if (token->type != JSMN_PRIMITIVE) return 0; + if (token == 0 || token->type != JSMN_PRIMITIVE) return 0; return strtol(json + token->start, 0, 0); } char* JsonObjectBase::getStringFromToken(jsmntok_t* token) { - if (token->type != JSMN_PRIMITIVE && token->type != JSMN_STRING) + if (token == 0 || token->type != JSMN_PRIMITIVE && token->type != JSMN_STRING) return 0; // add null terminator to the string