From 2f924671475b876d6d97d1336f27e4246d24acde Mon Sep 17 00:00:00 2001 From: Weipin Xia Date: Sun, 27 Jun 2021 11:05:58 +0800 Subject: [PATCH] Swift Client: Fix double deallocation --- native_client/swift/deepspeech_ios/DeepSpeech.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) } }