summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/parse/css21props.c5
-rw-r--r--src/utils/utils.h7
2 files changed, 9 insertions, 3 deletions
diff --git a/src/parse/css21props.c b/src/parse/css21props.c
index f69c067..811dbe3 100644
--- a/src/parse/css21props.c
+++ b/src/parse/css21props.c
@@ -1683,7 +1683,10 @@ css_error parse_font_weight(css_css21 *c,
if (token->lower.ptr == c->strings[INHERIT]) {
flags |= FLAG_INHERIT;
} else if (token->type == CSS_TOKEN_NUMBER) {
- int32_t num = integer_from_css_string(&token->lower);
+ size_t consumed = 0;
+ int32_t num = integer_from_css_string(&token->lower, &consumed);
+ if (consumed != token->lower.len)
+ return CSS_INVALID;
switch (num) {
case 100: value = FONT_WEIGHT_100; break;
case 200: value = FONT_WEIGHT_200; break;
diff --git a/src/utils/utils.h b/src/utils/utils.h
index d31278d..b165059 100644
--- a/src/utils/utils.h
+++ b/src/utils/utils.h
@@ -27,14 +27,15 @@
#define UNUSED(x) ((x)=(x))
#endif
-static inline int32_t integer_from_css_string(const css_string *string)
+static inline int32_t integer_from_css_string(const css_string *string,
+ size_t *consumed)
{
size_t len;
const uint8_t *ptr;
int sign = 1;
int32_t val = 0;
- if (string == NULL || string->len == 0)
+ if (string == NULL || string->len == 0 || consumed == NULL)
return 0;
len = string->len;
@@ -64,6 +65,8 @@ static inline int32_t integer_from_css_string(const css_string *string)
len--;
}
+ *consumed = ptr - string->ptr;
+
return val * sign;
}