summaryrefslogtreecommitdiff
path: root/src/stylesheet.h
diff options
context:
space:
mode:
authorMichael Orlitzky <michael@orlitzky.com>2023-08-12 20:03:01 -0400
committerMichael Drake <tlsa@netsurf-browser.org>2023-09-17 19:46:13 +0100
commite1996b60f4568abdae96989b1af3c64f05073def (patch)
treeed232141e09d18ec48562e977b67b68f71497b7c /src/stylesheet.h
parent365e3e252bc29408722e905703d90e53c980c732 (diff)
downloadlibcss-e1996b60f4568abdae96989b1af3c64f05073def.tar.gz
libcss-e1996b60f4568abdae96989b1af3c64f05073def.tar.bz2
src/stylesheet.h: set uses_revert flag for shorthand properties
Take for example the list-style and list-style-type properties; the former is a shorthand property that subsumes the latter. When the list-style-type property is parsed, the "flags" variable has its FLAG_REVERT bit set, and we call, css__stylesheet_style_appendOPV(result, CSS_PROP_LIST_STYLE_TYPE, flags, value); which then sets the "uses_revert" bit on the stylesheet: if ((flags & (0x7 << 1)) == FLAG_REVERT) { style->sheet->uses_revert = true; } In contrast, when list-style is parsed and a flag is found, we run error = css_stylesheet_style_flag_value(result, flag_value, CSS_PROP_LIST_STYLE_TYPE); which immediately delegates to css__stylesheet_style_append() and buildOPV() without checking if "uses_revert" needs to be set. This can lead to segfault when we try to revert to a state that we have not saved (Mantis bug 2854). Adding a FLAG_REVERT check to css_stylesheet_style_flag_value() fixes the issue for the shorthand properties listed in docs/Bytecode, most (but not all) of which experienced the crash. Closes: https://bugs.netsurf-browser.org/mantis/view.php?id=2854
Diffstat (limited to 'src/stylesheet.h')
-rw-r--r--src/stylesheet.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/stylesheet.h b/src/stylesheet.h
index 070508f..673bc95 100644
--- a/src/stylesheet.h
+++ b/src/stylesheet.h
@@ -272,8 +272,12 @@ static inline css_error css_stylesheet_style_unset(css_style *style,
static inline css_error css_stylesheet_style_flag_value(css_style *style,
enum flag_value flag_value, opcode_t opcode)
{
+ enum flag flag = flag_value << 1;
+ if (flag == FLAG_REVERT) {
+ style->sheet->uses_revert = true;
+ }
return css__stylesheet_style_append(style,
- buildOPV(opcode, flag_value << 1, 0));
+ buildOPV(opcode, flag, 0));
}
css_error css__stylesheet_selector_create(css_stylesheet *sheet,