Fix interface out of bounds error on MSYS2#155
Open
rory-cd wants to merge 1 commit intothoth-tech:mainfrom
Open
Fix interface out of bounds error on MSYS2#155rory-cd wants to merge 1 commit intothoth-tech:mainfrom
rory-cd wants to merge 1 commit intothoth-tech:mainfrom
Conversation
Added a guard clause to _update_row_layout, preventing a potential out of bounds error with the layout_widths vector. This error was observed in the UI test, which failed on MSYS2.
8 tasks
222448082Ashen
approved these changes
May 8, 2026
222448082Ashen
left a comment
There was a problem hiding this comment.
General Information
- Type of Change: Bug fix
Code Quality
- Repository: Correct. The PR is made to
splashkit-core. - Readability: High. The addition of the empty check is clear and concise.
- Maintainability: High. This prevents a common source of undefined behavior in C++ (accessing index 0 of an empty vector).
Functionality
- Correctness: The fix is correct. In functions like
single_line_layout()andstart_custom_layout(), thelayout_widthsvector is cleared:Without this check,container_stack.back().layout_widths.clear(); _update_row_layout();_update_row_layout()would attempt to access&container_stack.back().layout_widths[0], resulting in an out-of-bounds memory access. - Impact on Existing Functionality: This is a critical stability fix that prevents crashes when using custom or single-line layouts in the SplashKit interface module.
Testing
- Test Results: Logic check confirms that the added condition safely bypasses the layout update when no specific widths are defined, which is the expected behavior for a single-line or custom layout before columns are added.
Documentation
- Documentation: N/A for this minor but important logic fix.
Pull Request Details
- PR Description: Correctly identifies the out-of-bounds risk in the interface module.
- Checklist Completion: All relevant items reviewed.
Recommendations & Observations
|
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.
Description
Problem
Interfaces have a bug which can cause out-of-bounds errors in MSYS2. When running the UI test in MSYS2 via
sktest.exe, the following error is received:Cause
The error can be traced back to
interface.cpp, line 308 in the_update_row_layoutfunction, which has:sk_interface_set_layout(container_stack.back().layout_widths.size(), &container_stack.back().layout_widths[0], container_stack.back().layout_height);This line attempts to access the
layout_widthsvector's first element (container_stack.back().layout_widths[0]), but many callers of_update_row_layoutclearlayout_widthsbeforehand, meaning the vector is empty and the out-of-bounds error occurs.Fix
A simple guard has been added to
_update_row_layout, to check iflayout_widthsis empty before proceeding.Type of change
How Has This Been Tested?
Tested primarily using the UI test in
sktest.exein MSYS2 and WSL. Interface displays as expected, with no errors received:Testing Checklist
Note for Testers
There have been some reported issues running
sktest(at all) on MSYS2. Specifically, the animation test was found to loop indefinitely, and some users found the test runner was freezing even before tests were launched. This has been addressed in #132.Checklist