Conversation
Root cause: Accessing C arrays without bounds checking in MPToolbarController.m, specifically: - Empty spaceAfterIndices[] array was accessed on every iteration - flexibleSpaceAfterIndices[] could overflow when k >= 5 This undefined behavior existed since 2017 but only manifested as a crash on Intel Macs after ENABLE_HARDENED_RUNTIME=YES was added in November 2025. Hardened Runtime enforces stricter memory checks, exposing the buffer overflow. Fix: Add bounds checking before array access using sizeof() to calculate array lengths. This prevents all out-of-bounds access while preserving the existing toolbar layout behavior. Related to #169
Contributor
Code Coverage ReportCurrent Coverage: 32.84% Coverage Details (Summary) |
Closed
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.
Summary
Fixes the Intel Mac crash reported in #169 by adding bounds checking to prevent buffer overflow in toolbar initialization.
Root Cause
Buffer overflow in
MPToolbarController.mwhen accessing C arrays without bounds checking:spaceAfterIndices[]array was accessed on every iterationflexibleSpaceAfterIndices[]could overflow whenk >= 5This undefined behavior existed since 2017 but only crashed on Intel Macs after
ENABLE_HARDENED_RUNTIME=YESwas added in November 2025.Changes
sizeof()before array accessTesting
Related Issue
Related to #169