mirror of
https://github.com/Instagram/IGListKit
synced 2026-05-24 09:48:21 +00:00
|
Some checks failed
IGListKit CI / Run Danger (push) Has been cancelled
IGListKit CI / Unit Test macOS (push) Has been cancelled
IGListKit CI / Unit Test tvOS (push) Has been cancelled
IGListKit CI / Build Examples and UI tests. (push) Has been cancelled
IGListKit CI / CocoaPods Lint (push) Has been cancelled
IGListKit CI / Verify generate_spm_sources_layout.sh is not broken (push) Has been cancelled
IGListKit CI / Verify SPM build by invoking `xcodebuild` on Package.swift (push) Has been cancelled
IGListKit CI / Unit Test iOS (push) Has been cancelled
IGListKit CI / Verify Carthage build XCFramework (push) Has been cancelled
Summary: Fixes https://github.com/Instagram/IGListKit/issues/1578 Callers of `IGListDiff`/`IGListDiffPaths` may pass `NSMutableArray` instances backed by collections that are mutated on other threads. Because the diffing algorithm uses `__unsafe_unretained` pointers internally for performance, concurrent mutation can cause use-after-free heap corruption — typically manifesting as: ``` malloc: Incorrect checksum for freed object: probably modified after being freed. ``` inside `std::deque::push_back` during the entry `oldIndexes` stack growth. This change adds `[oldArray copy]` and `[newArray copy]` at the top of `IGListDiffing()`. For immutable `NSArray` inputs this is a no-op retain with zero overhead. For `NSMutableArray` inputs it creates an immutable snapshot, narrowing the race window from the entire O(n+m) diff to just the `-copy` call. This is a best-effort mitigation — callers are still responsible for not mutating the source array concurrently since `-[NSMutableArray copy]` itself is not atomic. Differential Revision: D101205956 fbshipit-source-id: 514ebbef1903c796c10fee23f4efb4dd9b3073bd |
||
|---|---|---|
| .. | ||
| Internal | ||
| IGListAssert.h | ||
| IGListBatchUpdateData.h | ||
| IGListBatchUpdateData.mm | ||
| IGListCompatibility.h | ||
| IGListDiff.h | ||
| IGListDiff.mm | ||
| IGListDiffable.h | ||
| IGListDiffKit.h | ||
| IGListExperiments.h | ||
| IGListIndexPathResult.h | ||
| IGListIndexPathResult.m | ||
| IGListIndexSetResult.h | ||
| IGListIndexSetResult.m | ||
| IGListMacros.h | ||
| IGListMoveIndex.h | ||
| IGListMoveIndex.m | ||
| IGListMoveIndexPath.h | ||
| IGListMoveIndexPath.m | ||
| NSNumber+IGListDiffable.h | ||
| NSNumber+IGListDiffable.m | ||
| NSString+IGListDiffable.h | ||
| NSString+IGListDiffable.m | ||