Skip to content

Fix buffer out-of-bounds in application example draw#4481

Open
TarekAS wants to merge 1 commit intorust-windowing:masterfrom
TarekAS:fix/application-example-draw-oob
Open

Fix buffer out-of-bounds in application example draw#4481
TarekAS wants to merge 1 commit intorust-windowing:masterfrom
TarekAS:fix/application-example-draw-oob

Conversation

@TarekAS
Copy link
Contributor

@TarekAS TarekAS commented Feb 8, 2026

Fixes broken example: #4480

At least on macOS

  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality

Edit: apologies for the long PR title, used the original commit message for it.

…f.window.surface_size() for loop bounds, but self.surface.buffer_mut() returns a buffer sized by the last resize() call. When the window resizes, surface_size() can return new dimensions before the buffer is resized to match, causing an index out-of-bounds panic. Store the size from resize() and use it in draw() instead.
Copy link
Member

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to think that the real bug here is that Winit updates Window::surface_size before the user has received an event for it, see also #3690.

In any case, this should also be fixed after rust-windowing/softbuffer#237 (which should land in the next version of softbuffer, because then the drawing always uses the actual bounds of the surface.

Idk. whether it makes sense to update the example in the meantime.

Edit: apologies for the long PR title, used the original commit message for it.

You can edit it ;)

@madsmtm madsmtm added DS - appkit Affects the AppKit/macOS backend S - docs Awareness, docs, examples, etc. labels Feb 8, 2026
@TarekAS TarekAS changed the title Fix buffer out-of-bounds in application example draw draw() used se… Fix buffer out-of-bounds in application example draw Feb 8, 2026
@TarekAS
Copy link
Contributor Author

TarekAS commented Feb 8, 2026

Would be great to fix the root cause of this issue. In the meantime, the application example is broken while it was working in 0.30. I had to do this workaround in order to contribute to another PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DS - appkit Affects the AppKit/macOS backend S - docs Awareness, docs, examples, etc.

Development

Successfully merging this pull request may close these issues.

2 participants