1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2025-04-28 17:47:22 -04:00

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

View file

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