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

menuItemNext being a wild pointer in certain circumstances #43

Closed
shezik opened this issue Nov 6, 2021 · 3 comments
Closed

menuItemNext being a wild pointer in certain circumstances #43

shezik opened this issue Nov 6, 2021 · 3 comments
Labels

Comments

@shezik
Copy link

shezik commented Nov 6, 2021

I'm working on an ESP32 project where everything GEM-related is dynamically allocated.
However LoadProhibited fatal error occurs when menu.drawMenu() is called. Turns out that pointer menuItemNext defined in GEMItem.h is wild and the issue disappears if menuItemNext is initialized with nullptr.

    GEMPage* parentPage = nullptr;  
    GEMPage* linkedPage;  
    GEMItem* menuItemNext = nullptr;  // <- Here
    void (*buttonAction)();

I wonder if this is because that all objects are dynamically allocated or just that I'm retarded (I did not dig too deep into the code).
Code can be provided if required. :)

@Spirik
Copy link
Owner

Spirik commented Nov 6, 2021

Good catch!

Yes, by all means menuItemNext should be initialized with nullptr by default. However, this error doesn't trigger during "normal" workflow (e.g. examples that come with GEM) and probably related to dynamic allocation in your case. And indeed the last menu item of the menu page may end up having menuItemNext left as an uninitialized wild pointer. Which is, of course, bad and should be avoided. So I will fix it on the next patch release. Thank you!

@Spirik Spirik added the bug label Nov 6, 2021
@Spirik
Copy link
Owner

Spirik commented Nov 7, 2021

Fix now available in 1.3.4 release. Please check, if this will work for you.

@shezik
Copy link
Author

shezik commented Nov 7, 2021

Fix now available in 1.3.4 release. Please check, if this will work for you.

It definitely does. Thank you for being so responsive! :D

@shezik shezik closed this as completed Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants