fix(font): Check FcNameParse return value

If FcNameParse returns NULL FcDefaultSubstitute segfaults

We log and throw an error here because the signal emitter swallows all
exceptions so if that exception was thrown, the bar would stop rendering
without any indication as to why.

Fixes #1435
This commit is contained in:
patrick96 2018-10-02 17:53:34 +02:00 committed by NBonaparte
parent 3c504bb913
commit 01f4957485

View File

@ -257,6 +257,12 @@ namespace cairo {
}); });
auto pattern = FcNameParse((FcChar8*)fontname.c_str()); auto pattern = FcNameParse((FcChar8*)fontname.c_str());
if(!pattern) {
logger::make().err("Could not parse font \"%s\"", fontname);
throw application_error("Could not parse font \"" + fontname + "\"");
}
FcDefaultSubstitute(pattern); FcDefaultSubstitute(pattern);
FcConfigSubstitute(nullptr, pattern, FcMatchPattern); FcConfigSubstitute(nullptr, pattern, FcMatchPattern);