Skip to content

Commit 47a3002

Browse files
author
Ary Borenszweig
committedJan 20, 2017
Fixed: use unused variable in String#<=>
Because all String end with a `\0` this isn't a real problem, as memcmp would stop at that `\0` so there's no unsafe memory access, but this change is still more correct.
1 parent 42e2a52 commit 47a3002

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎src/string.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2038,7 +2038,7 @@ class String
20382038
return 0 if same?(other)
20392039
min_bytesize = Math.min(bytesize, other.bytesize)
20402040

2041-
cmp = to_unsafe.memcmp(other.to_unsafe, bytesize)
2041+
cmp = to_unsafe.memcmp(other.to_unsafe, min_bytesize)
20422042
cmp == 0 ? (bytesize <=> other.bytesize) : cmp.sign
20432043
end
20442044

0 commit comments

Comments
 (0)
Please sign in to comment.