HuoLanguage / huo

interpreted language written in C
MIT License
213 stars 21 forks source link

Fixed-length buffers #11

Closed TheLoneWolfling closed 8 years ago

TheLoneWolfling commented 8 years ago

A program consisting of >= 256 zeros crashes. I haven't checked yet, but I suspect that many other tokens of length >= 256 will also crash.

Simple reproduction:

python -c 'print("0"*1000)' >crash.txt
huo crash.txt

Considering you're using longs internally anyways, it may be simplest to just throw an error if you get too many characters in a single token.

TheLoneWolfling commented 8 years ago

Yep, other tokens are affected. A thousand 'a's, or a string consisting of 1000 characters, will both crash it, for instance.

TheLoneWolfling commented 8 years ago

Also issue #9 comes into play here.

TheLoneWolfling commented 8 years ago

If I wrote up a patch to replace your fixed-length buffers with heap-allocated ones, would you accept it?

incrediblesound commented 8 years ago

Yes, in general I am pretty open about pull requests. If you do something to improve the code I'll definitely accept the pull request.