-
Notifications
You must be signed in to change notification settings - Fork 166
Open
Description
🚨 Critical Bug Report
Problem
The _unsafeWait function in podcasts/UnsafeWait.swift contains a critical crash vulnerability on line 16 where box.result! is force unwrapped. If the async operation fails or the semaphore times out, box.result could be nil, causing the app to crash.
Location
- File:
podcasts/UnsafeWait.swift - Line: 16
- Function:
_unsafeWait<T>(_ f: @escaping () async -> T) -> T
Impact
- Severity: Critical
- Risk: App crashes during async operations
- Affected: Video export functionality and any other code using
_unsafeWait
Root Cause
The function uses a DispatchSemaphore to bridge from synchronous to async code, but if the async operation fails or takes too long, the box.result remains nil. The force unwrap on line 16 then crashes the app.
Solution
A fix has been implemented that:
- Removes the dangerous force unwrap
- Adds proper error handling with timeout (30 seconds)
- Updates the function signature to handle throwing async functions
- Maintains backward compatibility
Testing
- ✅ Swift syntax validation passed
- ✅ No linting errors
- ✅ Proper error propagation implemented
Metadata
Metadata
Assignees
Labels
No labels