From fab1bbad735b87eee91bc09a477bc21973c72881 Mon Sep 17 00:00:00 2001 From: Leon Kiefer Date: Sun, 26 Sep 2021 12:56:28 +0200 Subject: [PATCH] fixed duplicate deallocation of stream streamCtx must be unset after STT_FreeStream was called in STT_FinishStreamWithMetadata, else STT_FreeStream is called again on destruction of STTStream resulting in EXC_BAD_ACCESS errors --- native_client/swift/stt_ios/STT.swift | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/native_client/swift/stt_ios/STT.swift b/native_client/swift/stt_ios/STT.swift index b1705f22..214e5ad2 100644 --- a/native_client/swift/stt_ios/STT.swift +++ b/native_client/swift/stt_ios/STT.swift @@ -283,7 +283,10 @@ public class STTStream { precondition(streamCtx != nil, "calling method on invalidated Stream") let result = STT_FinishStreamWithMetadata(streamCtx, UInt32(numResults))! - defer { STT_FreeMetadata(result) } + defer { + STT_FreeMetadata(result) + streamCtx = nil + } return STTMetadata(fromInternal: result) } }