-
Notifications
You must be signed in to change notification settings - Fork 577
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
Fix null deref with y_offset in nk_group and nk_listview #584
base: master
Are you sure you want to change the base?
Conversation
} else { | ||
y_offset = nk_find_value(win, id_hash+1); | ||
if (!y_offset) { | ||
y_offset = nk_add_value(ctx, win, id_hash+1, 0); | ||
NK_ASSERT(y_offset); | ||
if (!y_offset) return 0; | ||
*y_offset = 0; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good find, thanks a lot. Two things...
- Make sure to update the change in the
src
directory too. Otherwise the next time the paq.sh file is run, we'll lose this change. - Also, what do you think about updating this pattern in both
nuklear_group.c
andnuklear_list_view.c
too? Could probably run into the same issue there, as it's using a similar pattern.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Ah, right, sorry! I just ported the change from the vendored file in my project, I didn't read up on how development actually goes here. Sorry. Do I need to also edit
nuklear.h
or will that be handled automatically when you pack it up? - Yep, seems similar. Do you want the same change there as well, or do you have some nicer way to generalize it in mind?
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- No need to appologize. Can be confusing. You don't absolutely need to edit nuklear.h. Anyone can run the script and it'll get updated eventually. Whichever is easier for you
- Same way is fine 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. I left it as smaller commits, but let me know if you prefer a squash. Or just squash when merging.
We hit a rare null deref on
y_offset
innk_group_scrolled_offset_begin()
, that I think happens like this:First, we don't find the
x_offset
, so we go into the if() branch. There, we manage to addx_offset
but noty_offset
. This causes it to bail early. Then, next frame, it will findx_offset
and go into the else branch. There, it fails to findy_offset
, and eventually calls intonk_group_scrolled_offset_begin()
withy_offset = NULL
.Never got a local repro so can't say for sure if the existing
NK_ASSERT(y_offset)
was firing, but end user reports that this patch fixes it.I think this is one of the issues that was reported in #513