mirror of
https://github.com/janet-lang/janet
synced 2024-12-23 15:00:27 +00:00
fix janet_string_equalconst
Check string length before pointer equality, so that a string is not considered equal to a prefix slice of itself.
This commit is contained in:
parent
9f4497a5ae
commit
e2eb7ab4b2
@ -71,10 +71,10 @@ int janet_string_compare(const uint8_t *lhs, const uint8_t *rhs) {
|
||||
int janet_string_equalconst(const uint8_t *lhs, const uint8_t *rhs, int32_t rlen, int32_t rhash) {
|
||||
int32_t lhash = janet_string_hash(lhs);
|
||||
int32_t llen = janet_string_length(lhs);
|
||||
if (lhs == rhs)
|
||||
return 1;
|
||||
if (lhash != rhash || llen != rlen)
|
||||
return 0;
|
||||
if (lhs == rhs)
|
||||
return 1;
|
||||
return !memcmp(lhs, rhs, rlen);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user