c2lang / c2compiler

the c2 programming language
c2lang.org
Apache License 2.0
704 stars 49 forks source link

Segfault on parse error for invalid code #94

Closed Dandigit closed 5 years ago

Dandigit commented 5 years ago

This invalid code:

module test;

func void foo() {
    return;
}

public func i32 main(i32 argc, char*[] argv) {
    func void() v = foo;
    return 0;
}

...causes c2c to report the following error (as it should):

building target dummy
func_ptr.c2:8:5: error: expected expression
    func void() v = foo;
    ^

However, after the error is printed, c2c segfaults:

Segmentation fault (core dumped)

Additional info OS: Ubuntu 18.04.1 LTS Command run: c2c -f file.c2

bvdberg commented 5 years ago

Indeed, SkipUntil() got in an infinite loop.. Fixed in master.