mirror of
https://github.com/advplyr/audiobookshelf-app.git
synced 2026-07-26 22:48:43 +02:00
[PR #1016] [MERGED] [Fix] Prevent crash from force unwrapping nil value in PR-1005 #1492
Reference in New Issue
Block a user
📋 Pull Request Information
Original PR: https://github.com/advplyr/audiobookshelf-app/pull/1016
Author: @KaiStarkk
Created: 12/30/2023
Status: ✅ Merged
Merged: 12/31/2023
Merged by: @advplyr
Base:
master← Head:hotfix-pr-1005📝 Commits (1)
b2bfa4c[Fix] Prevent crash from force unwrapping nil value in PR #1005📊 Changes
1 file changed (+12 additions, -9 deletions)
View changed files
📝
ios/App/Shared/player/AudioPlayer.swift(+12 -9)📄 Description
In further testing I found a rare case where
selfwas not initialized when force unwrapping in the player, causing a runtime crash.This is now fixed, first
selfis captured weakly usingguard let, to avoid a strong reference cycle, and then safely unwrapped to astrongSelfconstant. Ifselfisnilwhen the closure is called, it will return.commandFailedand exit the closure, avoiding a crash. Ifselfis not nil, it will proceed as per PR #1005.Wasn't expecting self to ever be cleaned up by the memory manager, but it appears it's possible.
Referenced info on ARC
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.