diff --git a/src/style-internal.cpp b/src/style-internal.cpp index d5d43e30abeba7c4d772b1259b86769707278ab9..8c2386b752645046db664092d8eb25bfec12ef08 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -1511,14 +1511,14 @@ SPIPaint::read( gchar const *str ) { // << " document: " << (style->object->document?"yes":"no") << std::endl; // } - if(!str ) return; - - reset( false ); // Do not init - - // Is this necessary? - while (g_ascii_isspace(*str)) { + // Advance to the next non-space + while (str && g_ascii_isspace(*str)) { ++str; } + if(!str) + return; + + reset( false ); // Do not init if (streq(str, "inherit")) { set = true; @@ -1562,10 +1562,16 @@ SPIPaint::read( gchar const *str ) { } } - while ( g_ascii_isspace(*str) ) { + // Ignore spaces between elements + while ( str && g_ascii_isspace(*str) ) { ++str; } + if (!str) { + std::cerr << "SPIPaint::read(): value ended prematurely." << std::endl; + return; + } + if (streq(str, "currentColor")) { set = true; paintOrigin = SP_CSS_PAINT_ORIGIN_CURRENT_COLOR; @@ -1594,9 +1600,15 @@ SPIPaint::read( gchar const *str ) { setColor( rgb0 ); set = true; - while (g_ascii_isspace(*str)) { + // Ignore spaces between color and icc profile. + while (str && g_ascii_isspace(*str)) { ++str; } + if (!str) { + std::cerr << "SPIPaint::read(): value ended prematurely." << std::endl; + return; + } + if (strneq(str, "icc-color(", 10)) { SVGICCColor* tmp = new SVGICCColor(); if ( ! sp_svg_read_icc_color( str, &str, tmp ) ) {