Skip to content

Fix: CFRunLoopRemoveSource crash removing a source from the common modes - #143

Open
DTW-Thalion wants to merge 1 commit into
gnustep:masterfrom
DTW-Thalion:fix-cfrunloop-common-modes-remove
Open

Fix: CFRunLoopRemoveSource crash removing a source from the common modes#143
DTW-Thalion wants to merge 1 commit into
gnustep:masterfrom
DTW-Thalion:fix-cfrunloop-common-modes-remove

Conversation

@DTW-Thalion

Copy link
Copy Markdown
Contributor

CFRunLoopCommonModesRemove assigned the Boolean result of CFArrayContainsValue to a CFIndex and passed it to CFArrayRemoveValueAtIndex. Removing an object from kCFRunLoopCommonModes therefore removed index 1 when the object was present (or index 0 when it was absent) rather than the object's actual index, reading past the end of _commonObjects and crashing CFRunLoopRemoveSource/RemoveObserver/RemoveTimer for any object added to the common modes.

Use CFArrayGetFirstIndexOfValue, which returns the real index or kCFNotFound, matching CFRunLoopRemoveSource_nolock.

Tests/CFRunLoop/common_remove.m segfaults before this change and passes after. Verified against Apple CoreFoundation.

@DTW-Thalion
DTW-Thalion force-pushed the fix-cfrunloop-common-modes-remove branch from bc57e33 to 3193a4c Compare July 24, 2026 15:22
@DTW-Thalion DTW-Thalion reopened this Jul 24, 2026
@DTW-Thalion DTW-Thalion reopened this Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant