Skip to content

Commit

Permalink
Fix memory leak of pthread_key_t pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisamanse authored and kzaher committed Sep 29, 2017
1 parent 5588988 commit bd5a965
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion RxSwift/Schedulers/CurrentThreadScheduler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ public class CurrentThreadScheduler : ImmediateSchedulerType {

private static var isScheduleRequiredKey: pthread_key_t = { () -> pthread_key_t in
let key = UnsafeMutablePointer<pthread_key_t>.allocate(capacity: 1)
if pthread_key_create(key, nil) != 0 {
defer {
key.deallocate(capacity: 1)
}

guard pthread_key_create(key, nil) == 0 else {
rxFatalError("isScheduleRequired key creation failed")
}

Expand Down

0 comments on commit bd5a965

Please sign in to comment.