diff options
author | Nikias Bassen | 2014-09-20 01:03:33 +0200 |
---|---|---|
committer | Nikias Bassen | 2014-09-20 01:03:33 +0200 |
commit | 5ddbe5fa5ee011df10e288c405302a01e7c1dc71 (patch) | |
tree | 84e9be81b25271a8f6acf977b4a0c23aae8e5909 /src/String.cpp | |
parent | b6c43e901c1ee3ded15261621be1aaa090dab984 (diff) | |
download | libplist-5ddbe5fa5ee011df10e288c405302a01e7c1dc71.tar.gz libplist-5ddbe5fa5ee011df10e288c405302a01e7c1dc71.tar.bz2 |
C++: Make sure String::GetValue() and Key::GetValue() don't crash with NULL strings
Diffstat (limited to 'src/String.cpp')
-rw-r--r-- | src/String.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/String.cpp b/src/String.cpp index 09b47b5..0965349 100644 --- a/src/String.cpp +++ b/src/String.cpp @@ -67,8 +67,13 @@ std::string String::GetValue() const { char* s = NULL; plist_get_string_val(_node, &s); - std::string ret = s; - free(s); + std::string ret; + if (s) { + ret = s; + free(s); + } else { + ret = ""; + } return ret; } |