From: Sean Middleditch Date: Thu, 14 Jan 2010 02:35:07 +0000 (-0800) Subject: dont attempt to create a std::string from NULL in as_string() X-Git-Tag: v1.3~21^2~3^2~12 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=jansson.git;a=commitdiff_plain;h=69437a7183c4d7105fc5e85021642ab9a04eaf6b dont attempt to create a std::string from NULL in as_string() --- diff --git a/janssonxx.h b/janssonxx.h index 6703f95..b546f7e 100644 --- a/janssonxx.h +++ b/janssonxx.h @@ -155,7 +155,10 @@ public: // get value cast to specified type const char* as_cstring() const { return json_string_value(_value); } - std::string as_string() const { return as_cstring(); } + std::string as_string() const { + const char* tmp = as_cstring(); + return tmp == 0 ? "" : tmp; + } int as_integer() const { return json_integer_value(_value); } double as_real() const { return json_real_value(_value); } double as_number() const { return json_number_value(_value); }