From 5ddbe5fa5ee011df10e288c405302a01e7c1dc71 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Sat, 20 Sep 2014 01:03:33 +0200 Subject: C++: Make sure String::GetValue() and Key::GetValue() don't crash with NULL strings --- src/Key.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/Key.cpp') diff --git a/src/Key.cpp b/src/Key.cpp index e3ccbe6..ed0c0c6 100644 --- a/src/Key.cpp +++ b/src/Key.cpp @@ -67,8 +67,13 @@ std::string Key::GetValue() const { char* s = NULL; plist_get_key_val(_node, &s); - std::string ret = s; - free(s); + std::string ret; + if (s) { + ret = s; + free(s); + } else { + ret = ""; + } return ret; } -- cgit v1.1-32-gdbae