summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2018-03-30 16:32:25 +0000
committerTavmjong Bah <tavmjong@free.fr>2018-03-30 16:32:25 +0000
commit1ef5505df6860368fa048c3a5a8e8ef64e603ddf (patch)
treea27bb62e4cf9069edeff069c70c0e347d64e9cc3 /src
parentFix bug: 1758477 (diff)
downloadinkscape-1ef5505df6860368fa048c3a5a8e8ef64e603ddf.tar.gz
inkscape-1ef5505df6860368fa048c3a5a8e8ef64e603ddf.zip
Protect against empty string.
Diffstat (limited to 'src')
-rw-r--r--src/libnrtype/font-lister.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp
index 90a323b1a..e32dda063 100644
--- a/src/libnrtype/font-lister.cpp
+++ b/src/libnrtype/font-lister.cpp
@@ -770,23 +770,25 @@ void FontLister::fill_css(SPCSSAttr *css, Glib::ustring fontspec)
std::vector<Glib::ustring> tokens = Glib::Regex::split_simple(",", str);
- Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create("(\\w{4})=([-+]?\\d*\\.?\\d+([eE][-+]?\\d+)?)");
- Glib::MatchInfo matchInfo;
- for (auto token: tokens) {
- regex->match(token, matchInfo);
- if (matchInfo.matches()) {
- variations += "'";
- variations += matchInfo.fetch(1);
- variations += "' ";
- variations += matchInfo.fetch(2);
- variations += ", ";
+ if (str) {
+ Glib::RefPtr<Glib::Regex> regex = Glib::Regex::create("(\\w{4})=([-+]?\\d*\\.?\\d+([eE][-+]?\\d+)?)");
+ Glib::MatchInfo matchInfo;
+ for (auto token: tokens) {
+ regex->match(token, matchInfo);
+ if (matchInfo.matches()) {
+ variations += "'";
+ variations += matchInfo.fetch(1);
+ variations += "' ";
+ variations += matchInfo.fetch(2);
+ variations += ", ";
+ }
}
+ if (variations.length() >= 2) { // Remove last comma/space
+ variations.pop_back();
+ variations.pop_back();
+ }
+ sp_repr_css_set_property(css, "font-variation-settings", variations.c_str());
}
- if (variations.length() >= 2) { // Remove last comma/space
- variations.pop_back();
- variations.pop_back();
- }
- sp_repr_css_set_property(css, "font-variation-settings", variations.c_str());
#endif
}