EwenQuim / renpy-graphviz

Draws a flowchart graph of any Visual Novel from Renpy .rpy files !
https://ewenquim.github.io/renpy-graphviz/
GNU Affero General Public License v3.0
132 stars 4 forks source link

Segfault on jump after return #9

Closed alk0 closed 3 years ago

alk0 commented 3 years ago
label a:
    return
    jump b

panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x50a616]

goroutine 1 [running]: pkg.amethysts.studio/renpy-graphviz/parser.(*RenpyGraph).AddEdge(0xc000123d80, 0x0, 0x0, 0xc000123de0, 0x3, 0x3) renpy-graphviz/parser/graph.go:115 +0x136 pkg.amethysts.studio/renpy-graphviz/parser.Graph(0xc000062180, 0x4, 0x4, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0) renpy-graphviz/parser/parser.go:48 +0x50f main.main() renpy-graphviz/main.go:17 +0xa5

The logic in the example is faulty, but it doesn't break RenPy, so it shouldn't break renpy-graphviz either. A call or a duplicate return or "" after return don't crash the tool, so, without digging deep into the source I can't figure out why jump does.

EwenQuim commented 3 years ago

Currently, the jump needs a previous label as "root" to draw the arrow, and the "return" breaks it.

The feature causing this segfault was made to act like a BREAK tag (avoiding implicit jumps after a return keyword). I didn't care about fixing it since it is not a desired Ren'Py behaviour: that's not a priority.

I get that this can be annoying, so I'll fix it. Thanks for noticing!

EwenQuim commented 3 years ago

This is fixed now, you can test if you want, but that's included in my test suite :)

I hope you'll like my changes, and please star the repo if you do! That would be nice because I work on this during my spare time, and it helps me stay motivated, I hope you'll understand. Have a good week-end.