[PR #682] [MERGED] Fix "unowned self" that can cause crash #720

Closed
opened 2026-03-03 17:29:50 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/OAuthSwift/OAuthSwift/pull/682
Author: @MarkJerde
Created: 11/9/2021
Status: Merged
Merged: 12/3/2021
Merged by: @phimage

Base: masterHead: fix_unowned_self


📝 Commits (1)

📊 Changes

1 file changed (+2 additions, -2 deletions)

View changed files

📝 Sources/Handler/OAuthWebViewController.swift (+2 -2)

📄 Description

With an unowned self the reference to self can become nil without the ability for the code to be aware. As such, unowned self should be used when we know something else is guaranteed to retain a reference to our self. In this case there is no such guarantee. Fortunately, we can use a weak self to have nullability safety here without any performance
concerns.

This was noticed when it caused a crash in our app due to a particular series of events which resulted in this getting called after we had already gotten rid of the OAuthWebViewController.

Thank you, and thanks for OAuthSwift!


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/OAuthSwift/OAuthSwift/pull/682 **Author:** [@MarkJerde](https://github.com/MarkJerde) **Created:** 11/9/2021 **Status:** ✅ Merged **Merged:** 12/3/2021 **Merged by:** [@phimage](https://github.com/phimage) **Base:** `master` ← **Head:** `fix_unowned_self` --- ### 📝 Commits (1) - [`d2dc4cd`](https://github.com/OAuthSwift/OAuthSwift/commit/d2dc4cdc7a191302f0c9646f9490bd44340fac5c) Fix unowned self ### 📊 Changes **1 file changed** (+2 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `Sources/Handler/OAuthWebViewController.swift` (+2 -2) </details> ### 📄 Description With an `unowned self` the reference to self can become nil without the ability for the code to be aware. As such, `unowned self` should be used when we know something else is guaranteed to retain a reference to our self. In this case there is no such guarantee. Fortunately, we can use a `weak self` to have nullability safety here without any performance concerns. This was noticed when it caused a crash in our app due to a particular series of events which resulted in this getting called after we had already gotten rid of the OAuthWebViewController. Thank you, and thanks for OAuthSwift! --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-03 17:29:50 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/OAuthSwift#720
No description provided.