From 01f49574853176f4ea164d95226bcec6053ce74c Mon Sep 17 00:00:00 2001
From: patrick96
Date: Tue, 2 Oct 2018 17:53:34 +0200
Subject: [PATCH] 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
---
include/cairo/font.hpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/cairo/font.hpp b/include/cairo/font.hpp
index 1a904e95..fdefea47 100644
--- a/include/cairo/font.hpp
+++ b/include/cairo/font.hpp
@@ -257,6 +257,12 @@ namespace cairo {
});
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);
FcConfigSubstitute(nullptr, pattern, FcMatchPattern);