Fix macOS StorageProvider null pointer bugs by NathanDrake2406 · Pull Request #21115 · AvaloniaUI/Avalonia (original) (raw)
added 2 commits
The null check on line 401 tested fileUri instead of filePathUri,
making it dead code since fileUri was already checked on line 394.
When [fileUri filePathURL] returned nil (non-file URL or unreachable
resource), the nil filePathUri was passed to [filePathUri absoluteString]
and then to CreateAvnString, causing a native crash.
NSError* was declared without initialization, containing stack garbage.
On the success path (bookmarkData non-nil), Cocoa does not guarantee
zeroing the error out-parameter, so the subsequent if (error != nil)
check could read garbage and incorrectly call CreateAvnString with a
garbage pointer.
Initialize to nil and restructure to else if so the error is only
inspected when bookmarkData is nil (the failure path).
Copilot AI review requested due to automatic review settings
Initialize *ppv to nullptr on entry so callers never read garbage on the nil-fileUri / nil-bookmarkData paths. Guard *err write with a nullptr check for callers that pass no error out-parameter.
Merged via the queue into AvaloniaUI:master with commit 351e627
10 checks passed
MrJul added a commit to MrJul/Avalonia that referenced this pull request
- fix: correct null check variable in TryResolveFileReferenceUri on macOS
The null check on line 401 tested fileUri instead of filePathUri,
making it dead code since fileUri was already checked on line 394.
When [fileUri filePathURL] returned nil (non-file URL or unreachable
resource), the nil filePathUri was passed to [filePathUri absoluteString]
and then to CreateAvnString, causing a native crash.
- fix: initialize NSError to nil in SaveBookmarkToBytes on macOS
NSError* was declared without initialization, containing stack garbage.
On the success path (bookmarkData non-nil), Cocoa does not guarantee
zeroing the error out-parameter, so the subsequent if (error != nil)
check could read garbage and incorrectly call CreateAvnString with a
garbage pointer.
Initialize to nil and restructure to else if so the error is only
inspected when bookmarkData is nil (the failure path).
chore: retrigger CI
fix: guard out-parameters in SaveBookmarkToBytes
Initialize *ppv to nullptr on entry so callers never read garbage on the nil-fileUri / nil-bookmarkData paths. Guard *err write with a nullptr check for callers that pass no error out-parameter.
- chore: retrigger CI
Co-authored-by: Julien Lebosquain julien@lebosquain.net
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
[ Show hidden characters]({{ revealButtonHref }})