diff --git a/native_client/swift/deepspeech_ios/DeepSpeech.swift b/native_client/swift/deepspeech_ios/DeepSpeech.swift index 77a6a81817..43d2669bfd 100644 --- a/native_client/swift/deepspeech_ios/DeepSpeech.swift +++ b/native_client/swift/deepspeech_ios/DeepSpeech.swift @@ -283,7 +283,10 @@ public class DeepSpeechStream { precondition(streamCtx != nil, "calling method on invalidated Stream") let result = DS_FinishStreamWithMetadata(streamCtx, UInt32(numResults))! - defer { DS_FreeMetadata(result) } + defer { + DS_FreeMetadata(result) + streamCtx = nil + } return DeepSpeechMetadata(fromInternal: result) } }