justinmeza / lci

A LOLCODE interpreter written in C.
http://lolcode.org
GNU General Public License v3.0
780 stars 105 forks source link

segfault #33

Closed initbar closed 8 years ago

initbar commented 8 years ago

While playing with lolcode, I've isolated the segfaulting code:

HAI 1.2
I HAS A VAR ITZ 1
VAR R ":{VAR}"
VISIBLE VAR
KTHXBYE

In here, the segfault happens only when VISIBLE VAR is called. I think the problem is with this line:

VAR R "{:VAR}"

after string interpolation of VAR and overwriting self.

justinmeza commented 8 years ago

Thanks for finding this!

The interpreter tries to interpolate string lazily, so after the line VAR R ":{VAR}" is executed, the value of VAR is ":{VAR}". When VAR is eventually interpolated in VISIBLE VAR, the interpreter tries to expand it to ":{:{...:{VAR}...}}" and runs out of memory.

To solve this problem, I will patch the interpreter to interpolate assigned strings.

justinmeza commented 8 years ago

Commit d42043c fixes this issue. I also patched the future branch. Thanks again, @initbar!