hugoif / hugo-unix

A fork of Bill Lash's Hugo port, originally hosted at https://bitbucket.org/0branch/hugo-unix. Further info and downloads: http://www.generalcoffee.com/hugo/gethugo.html.
BSD 2-Clause "Simplified" License
7 stars 5 forks source link

Fix for invalid game files being generated on Unix #2

Closed juhana closed 3 years ago

juhana commented 3 years ago

Moved array initialization outside a loop to avoid undefined behavior. Fixes the issue discussed at https://intfiction.org/t/hugo-unix-compiler-crashes-when-referring-to-consecutive-nouns/48782/7

Related to this, I find this piece of code inside the loop a bit suspect but I don't really know what it's doing to tell if it's working correctly or not: https://github.com/0branch/hugo-unix/blob/456ca639aa1afcb4aab7f8ea2b41756b1804fb2e/source/hccode.c#L1002-L1011

To me it seems like as j grows it checks all tokens for ROUTINE_T and ARRAY_T, not just the "initial value" (although I don't know what that means exactly so maybe there's no problem here.)

Also, I couldn't make j larger than 6 regardless of how many commas there were in the comparison. If there's some way for it to become larger than 14 then there should be a separate check to avoid overshooting the array.