Fix buffer out-of-bounds in application example draw#4481
Open
TarekAS wants to merge 1 commit intorust-windowing:masterfrom
Open
Fix buffer out-of-bounds in application example draw#4481TarekAS wants to merge 1 commit intorust-windowing:masterfrom
TarekAS wants to merge 1 commit intorust-windowing:masterfrom
Conversation
…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.
madsmtm
reviewed
Feb 8, 2026
Member
madsmtm
left a comment
There was a problem hiding this comment.
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 ;)
Contributor
Author
|
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes broken example: #4480
At least on macOS
changelogmodule if knowledge of this change could be valuable to usersEdit: apologies for the long PR title, used the original commit message for it.