cpp: Fix init of string from null

* lang/cpp/src/key.cpp (UserID::addrSpecFromString): Check return
value before creating the string.
This commit is contained in:
Andre Heinecke 2016-10-14 16:23:57 +02:00
parent f526d0e22e
commit 1e8c34a919

View File

@ -884,9 +884,12 @@ std::string UserID::addrSpecFromString(const char *userid)
return std::string();
}
char *normalized = gpgme_addrspec_from_uid (userid);
std::string ret(normalized);
gpgme_free(normalized);
return ret;
if (normalized) {
std::string ret(normalized);
gpgme_free(normalized);
return ret;
}
return std::string();
}
std::string UserID::addrSpec() const