Skip to content

fix janet_string_equalconst#1519

Merged
bakpakin merged 1 commit intojanet-lang:masterfrom
ianthehenry:fix-string-equal-with-byteview
Nov 17, 2024
Merged

fix janet_string_equalconst#1519
bakpakin merged 1 commit intojanet-lang:masterfrom
ianthehenry:fix-string-equal-with-byteview

Conversation

@ianthehenry
Copy link
Contributor

Check string length before pointer equality, so that a string is not considered equal to a prefix slice of itself.

I ran into this with a pretty gnarly bug where e.g. (symbol/slice 'abcdefg 0 3) returned 'abcdefg when the symcache was filled just so -- they hash differently, but if you get unlucky enough and there's a hash collision, the resolution runs janet_string_equalconst and erroneously says "oh yeah we found it" because cfun_symbol_slice just changes the len.

Check string length before pointer equality, so that a string is not considered
equal to a prefix slice of itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants