SVG parse_svg_value/parse_font_size: re-initialise default val on parser failure

This commit is contained in:
Artem Pavlenko 2021-04-19 08:54:34 +01:00
parent 4ff25eb2a8
commit 3031b7cf6a

View file

@ -268,15 +268,16 @@ double parse_svg_value(T & parser, char const* str, bool & is_percent)
x3::space) || (cur != end))
{
parser.err_handler().on_error("SVG parse error: failed to parse <number> with value \"" + std::string(str) + "\"");
val = 0.0; // re-initialise to default value
}
return val;
}
template <typename T>
double parse_font_size(T & parser, char const* str)
bool parse_font_size(T & parser, char const* str)
{
namespace x3 = boost::spirit::x3;
double val;
double val = 0.0;
css_unit_value units;
css_absolute_size absolute;
css_relative_size relative;
@ -303,9 +304,10 @@ double parse_font_size(T & parser, char const* str)
x3::space) || (cur != end))
{
parser.err_handler().on_error("SVG parse error: failed to parse <font-size> with value \"" + std::string(str) + "\"");
return false;
}
if (!parser.font_sizes_.empty()) parser.font_sizes_.back() = val;
return val;
return true;
}
template <typename T, typename V>