From b1fec625643618a452548801fbc5f9dbf0c2429f Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Fri, 31 May 2024 20:41:00 +0300 Subject: [PATCH] Fix a potential crash upon pausing in iOS and macOS --- Cocoa/Document.m | 3 +-- iOS/GBViewController.m | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Cocoa/Document.m b/Cocoa/Document.m index c7640dd1e..ab0037361 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -564,8 +564,7 @@ - (void)postRun { [_hexTimer invalidate]; [_audioLock lock]; - memset(_audioBuffer, 0, (_audioBufferSize - _audioBufferPosition) * sizeof(*_audioBuffer)); - _audioBufferPosition = _audioBufferNeeded; + _audioBufferPosition = _audioBufferNeeded = 0; [_audioLock signal]; [_audioLock unlock]; [_audioClient stop]; diff --git a/iOS/GBViewController.m b/iOS/GBViewController.m index 5a95f7d7e..c67a89096 100644 --- a/iOS/GBViewController.m +++ b/iOS/GBViewController.m @@ -891,10 +891,7 @@ - (UIImage *)imageFromData:(NSData *)data width:(unsigned)width height:(unsigned - (void)postRun { [_audioLock lock]; - if (_audioBuffer) { - memset(_audioBuffer, 0, (_audioBufferSize - _audioBufferPosition) * sizeof(*_audioBuffer)); - } - _audioBufferPosition = _audioBufferNeeded; + _audioBufferPosition = _audioBufferNeeded = 0; [_audioLock signal]; [_audioLock unlock]; [_audioClient stop];