From 69437a7183c4d7105fc5e85021642ab9a04eaf6b Mon Sep 17 00:00:00 2001 From: Sean Middleditch Date: Wed, 13 Jan 2010 18:35:07 -0800 Subject: [PATCH] dont attempt to create a std::string from NULL in as_string() --- janssonxx.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); }