Skip to content

Commit e2833d3

Browse files
committed
parse: language: Unsigned difference expression compared to zero
Squash CodeQL `cpp/unsigned-difference-expression-compared-zero` issues. This rule finds relational comparisons between the result of an unsigned subtraction and the value `0`. Such comparisons are likely to be wrong as the value of an unsigned subtraction can never be negative. So the relational comparison ends up checking whether the result of the subtraction is equal to 0. This is probably not what the programmer intended.
1 parent 9d851c0 commit e2833d3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/parse/language.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,15 +1194,15 @@ css_error parseNth(css_language *c,
11941194
data[consumed] != 'N'))
11951195
return CSS_INVALID;
11961196

1197-
if (len - (++consumed) > 0) {
1197+
if (++consumed < len) {
11981198
if (data[consumed] != '-')
11991199
return CSS_INVALID;
12001200

12011201
/* 2n- */
12021202
sign = -1;
12031203
had_sign = true;
12041204

1205-
if (len - (++consumed) > 0) {
1205+
if (++consumed < len) {
12061206
size_t bstart;
12071207

12081208
/* Reject additional sign */

0 commit comments

Comments
 (0)