From d8855fd2c6b11b3316950754038f86e65163dad8 Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Mon, 30 Oct 2017 08:38:20 +0100 Subject: [PATCH] json::escape_string: if str is null return empty string --- src/main/cpp/json.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/cpp/json.cpp b/src/main/cpp/json.cpp index 16e0a7d..cbe443a 100644 --- a/src/main/cpp/json.cpp +++ b/src/main/cpp/json.cpp @@ -23,6 +23,10 @@ namespace json { std::string escape_string(const char *str) { + if (!str) { + return ""; + } + std::string result; // Create a sufficient buffer to escape all chars result.reserve(strlen(str) * 2 + 3);