mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:15:51 +01:00
[PR #2054] runtime: guard window-fit zero dimensions, signed overflow, and OOM in lifecycle shim #2060
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#2060
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/2054
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:rt/lifecycle-fit-window-bounds-and-overflow📝 Commits (1)
892f627runtime: guard window-fit zero dimensions, signed overflow, and OOM in lifecycle shim📊 Changes
2 files changed (+44 additions, -11 deletions)
View changed files
📝
runtime/shims/lifecycle.cpp(+30 -11)📝
runtime/test/lifecycle_test.cpp(+14 -0)📄 Description
Claim ID:
RT-LIFECYCLE-FIT-WINDOW-BOUNDS-AND-OVERFLOWSummary
Hardens window fitting, centering, and registration in
runtime/shims/lifecycle.cpp:fit_window_to_area(): Extreme aspect ratios (e.g.,4000x2or2x4000into a1000x1000work area) previously truncated the minor axis to0, passing a zero-width or zero-height window toCreateWindowEx. Clamping both fitted axes to[1, min(area_span, INT_MAX)]guarantees valid non-zero dimensions that fit inside the work area while preserving exact results for normal aspect ratios (3840x2160->1848x1040).fit_window_to_area()andprepare_title_window()now computearea.right - area.left,area.bottom - area.top, and centered(x, y)coordinates instd::int64_tbefore clamping toint.register_app_state_change(): Skip ID0ifg_next_reg_idever wraps so a registration handle never collides withnullptr, and catchstd::bad_alloc->ERROR_NOT_ENOUGH_MEMORYinstead of unwinding a C++ exception acrossWINAPI.runtime/test/lifecycle_test.cppwith extreme wide/tall aspect ratio, wide virtual-desktop span (> INT_MAX), and empty work-area checks.Verification
runtime/shims/lifecycle.cppwith minimal Win32/shim stubs; Windows MSVC CI run oflifecyclepending)clang++ -std=c++20 -O1 -g -fsanitize=address,undefined -Wall -Wextra -Werror: PASS (failures=0)clang++ -std=c++20 -O1 -g -fsanitize=thread -Wall -Wextra -Werror(4 threads x 500 concurrent register/unregister + suspend dispatch + window fit/centering): PASS (failures=0)clang++ -std=c++20 -O2 -Wall -Wextra -Werror: PASS (failures=0)mainunder UBSan: triggeredruntime error: signed integer overflow: 2000000000 - -2000000000 cannot be represented in type 'LONG'atlifecycle.cpp:208and failed all 4 new assertions (main_exit=1).python3 -I scripts/check_no_game_data.pyclean;python3 -I tests/test_text_write_line_endings.py(3/3 OK).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.