Commit 5ddbe5fa authored by Nikias Bassen's avatar Nikias Bassen

C++: Make sure String::GetValue() and Key::GetValue() don't crash with NULL strings

parent b6c43e90
...@@ -67,8 +67,13 @@ std::string Key::GetValue() const ...@@ -67,8 +67,13 @@ std::string Key::GetValue() const
{ {
char* s = NULL; char* s = NULL;
plist_get_key_val(_node, &s); plist_get_key_val(_node, &s);
std::string ret = s; std::string ret;
free(s); if (s) {
ret = s;
free(s);
} else {
ret = "";
}
return ret; return ret;
} }
......
...@@ -67,8 +67,13 @@ std::string String::GetValue() const ...@@ -67,8 +67,13 @@ std::string String::GetValue() const
{ {
char* s = NULL; char* s = NULL;
plist_get_string_val(_node, &s); plist_get_string_val(_node, &s);
std::string ret = s; std::string ret;
free(s); if (s) {
ret = s;
free(s);
} else {
ret = "";
}
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment