TarCV / botc

Fork of Dusk's botc compiler *OPEN FOR ADOPTION*
Other
1 stars 0 forks source link

Silent crash on encountering undefined variable #2

Closed TarCV closed 4 years ago

ghost commented 4 years ago

https://github.com/TarCV/botc/blob/99dbd44f9aa5d9d0469d9b190450a91fe5576a04/src/parser.cpp#L1288 https://github.com/TarCV/botc/blob/99dbd44f9aa5d9d0469d9b190450a91fe5576a04/src/format.h#L258 Issue is likely caused by a missing null terminator in var->name.

ghost commented 4 years ago

name is a member of Variable, and the data is obtained through findVariable, which appears to be where the issue resides: https://github.com/TarCV/botc/blob/99dbd44f9aa5d9d0469d9b190450a91fe5576a04/src/parser.cpp#L1285 https://github.com/TarCV/botc/blob/99dbd44f9aa5d9d0469d9b190450a91fe5576a04/src/parser.cpp#L1435

ghost commented 4 years ago

https://github.com/TarCV/botc/blob/99dbd44f9aa5d9d0469d9b190450a91fe5576a04/src/parser.cpp#L1288

To fix this, change that to: error ("unknown variable $%1", getTokenString());

TarCV commented 4 years ago

Thank you. Could you check that #8 works? My C++ build environment is broken currently, so I'll not be able to check it for some time.

ghost commented 4 years ago

I posted a comment there, but answering here as well: it does work.