Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Crash when parsing pattern with undefined struct inside conditional #1646

Open
1 task done
bgilbert opened this issue Apr 30, 2024 · 1 comment
Open
1 task done
Labels
bug Something isn't working

Comments

@bgilbert
Copy link

Operating System

Linux

What's the issue you encountered?

Parsing this pattern crashes ImHex:

struct Foo {
    u8 v;
    if (v == 0) {
        Missing m;
    }
};

Foo foo @ 0;

How can the issue be reproduced?

See above

ImHex Version

v1.33.0-184-gef99e9d6f8db

ImHex Build Type

  • Nightly or built from sources

Installation type

Source

Additional context?

This correctly throws a parse error:

struct Foo {
    u8 v;
    Missing m;
};

Foo foo @ 0;
@bgilbert bgilbert added the bug Something isn't working label Apr 30, 2024
@paxcut
Copy link
Contributor

paxcut commented Apr 30, 2024

Most likely due to the creation of nullptr nodes that were assumed to be impossible to create but was recently found not to be the case. when there is missing or incorrect notation inside loops or conditionals, these AST node pointers are created which point to zero.Then the nodes attempt to clone themselves using ptr->clone() which raises an invalid address exception crashing Imhex. The reason why these nodes are created and how to avoid them has to do with smart pointers and how they handle special cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants