Skip to content

Commit a2ab069

Browse files
committed
lex: Unsigned difference expression compared to zero
Squash CodeQL `cpp/unsigned-difference-expression-compared-zero` issue. 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 51587e0 commit a2ab069

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lex/lex.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ css_error Hash(css_lexer *lexer, css_token **token)
881881
return error;
882882

883883
/* Require at least one NMChar otherwise, we're just a raw '#' */
884-
if (lexer->bytesReadForToken - lexer->context.origBytes > 0)
884+
if (lexer->bytesReadForToken > lexer->context.origBytes)
885885
return emitToken(lexer, CSS_TOKEN_HASH, token);
886886

887887
return emitToken(lexer, CSS_TOKEN_CHAR, token);

0 commit comments

Comments
 (0)