fix(xrsources): Safety check

Refs #356
This commit is contained in:
Michael Carlberg 2017-01-19 20:19:17 +01:00
parent 9e3a7cf06c
commit 374ad655ae
1 changed files with 8 additions and 9 deletions

View File

@ -72,17 +72,16 @@ int xresource_manager::get_int(string name, int fallback) const {
* Query the database for given key
*/
string xresource_manager::load_value(const string& key, const string& res_type, size_t n) const {
if (m_manager == nullptr) {
return "";
}
char* type = nullptr;
XrmValue ret{};
XrmGetResource(m_db, key.c_str(), res_type.c_str(), &type, &ret);
if (m_manager != nullptr && m_db != nullptr) {
char* type = nullptr;
XrmValue ret{};
if (ret.addr != nullptr && !std::strncmp(res_type.c_str(), type, n)) {
return {ret.addr};
if (XrmGetResource(m_db, key.c_str(), res_type.c_str(), &type, &ret)) {
if (ret.addr != nullptr && !std::strncmp(res_type.c_str(), type, n)) {
return {ret.addr};
}
}
}
return "";
}