Skip to content

Commit c462d4e

Browse files
committed
core: string: 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 c98d3ba commit c462d4e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/core/string.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ dom_exception dom_string_replace(dom_string *target,
826826
}
827827

828828
/* Copy remainder of target, if any, into result */
829-
if (tlen - b2 > 0) {
829+
if (b2 < tlen) {
830830
memcpy(res->data.cdata.ptr + b1 + slen, t + b2, tlen - b2);
831831
}
832832

0 commit comments

Comments
 (0)