diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2018-03-30 16:32:25 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2018-03-30 16:32:25 +0000 |
| commit | 1ef5505df6860368fa048c3a5a8e8ef64e603ddf (patch) | |
| tree | a27bb62e4cf9069edeff069c70c0e347d64e9cc3 /src | |
| parent | Fix bug: 1758477 (diff) | |
| download | inkscape-1ef5505df6860368fa048c3a5a8e8ef64e603ddf.tar.gz inkscape-1ef5505df6860368fa048c3a5a8e8ef64e603ddf.zip | |
Protect against empty string.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libnrtype/font-lister.cpp | 32 |
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 } |
