I'm guessing that this is probably because tok->len can sometimes be longer than the string stored in op, so memcmp can sometimes access memory out of bounds.
Using strncmp here instead of memcmp seems to fix the issue.
I would open a pull request, but I read your README, and figured you probably want to make the change yourself :p
On the other hand, I don't think this would ever actually be an issue at runtime, so if you don't think this issue is worth the hassle of rebasing, please feel free to just close and ignore this issue :)
I was just testing out chibicc on a mac with
and the address sanitizer complains about this line:
https://github.com/rui314/chibicc/blob/90d1f7f199cc55b13c7fdb5839d1409806633fdb/tokenize.c#L80
I'm guessing that this is probably because
tok->len
can sometimes be longer than the string stored inop
, somemcmp
can sometimes access memory out of bounds.Using
strncmp
here instead ofmemcmp
seems to fix the issue.I would open a pull request, but I read your README, and figured you probably want to make the change yourself :p
On the other hand, I don't think this would ever actually be an issue at runtime, so if you don't think this issue is worth the hassle of rebasing, please feel free to just close and ignore this issue :)
best,