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

Out of bounds access in paint_uniform_rectangle #18

Open
KasumiArai opened this issue Jan 20, 2022 · 1 comment
Open

Out of bounds access in paint_uniform_rectangle #18

KasumiArai opened this issue Jan 20, 2022 · 1 comment

Comments

@KasumiArai
Copy link

I put together the imgui demo containing ImGui::ShowDemoWindow() (the same imgui commit contained in third_party) with this software renderer, and had a consistent crash when opening Widgets, Color/Picker Widgets in the demo window. The Windows 10 window size was 889x528. The position and size of the demo window (as reported by imgui.ini):
[Window][ImGui Demo]
Pos=75,38
Size=691,3418
Collapsed=0

I believe I traced the issue to this line:

uint32_t last_target_pixel = target.pixels[min_y_i * target.width + min_x_i];

max_y_i and min_y_i were both 528. That would prevent the for loops from drawing a row, but the last_target_pixel line still accessed memory beforehand. To fix, I set last_target_pixel to 0, as was done here:
uint32_t last_target_pixel = 0;

Apologies if a pull request might have been preferred. I was not sure if I should do so unsolicited.

Thanks for putting this together, it has been a massive help for a certain project of mine

@emilk
Copy link
Owner

emilk commented Jan 21, 2022

The problem is that paint_uniform_rectangle needs an early-out before indexing into target.pixels:

if (max_x_i <= min_x_i || max_y_i <= min_y_i) {
    return;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants