samiparse: Check that the string has a non-zero length before overwriting the last byte with '\0'

https://bugzilla.gnome.org/show_bug.cgi?id=777502
This commit is contained in:
Sebastian Dröge 2017-01-20 08:02:38 +02:00
parent ef55c8a6b7
commit d894c19db6

View file

@ -504,7 +504,8 @@ html_context_handle_element (HtmlContext * ctxt,
}
length = strlen (attr_value);
if (attr_value[length - 1] == '"' || attr_value[length - 1] == '\'') {
if (length > 0 && (attr_value[length - 1] == '"'
|| attr_value[length - 1] == '\'')) {
attr_value[length - 1] = '\0';
}