diff options
author | Joel Fischer <joeljfischer@gmail.com> | 2019-10-14 11:13:23 -0400 |
---|---|---|
committer | Joel Fischer <joeljfischer@gmail.com> | 2019-10-14 11:13:23 -0400 |
commit | 25584cd3f14de5cc8bc33925c8c2407416c38ec0 (patch) | |
tree | 1e737a9faf94cc5c91b87a9fd512763fc584a673 | |
parent | af56e0aefed929e63efe7c991979d0c255e6f694 (diff) | |
download | sdl_ios-bugfix/issue-1433-mutabledatabuffer-bounds.tar.gz |
Add a check before popping the bufferbugfix/issue-1433-mutabledatabuffer-bounds
-rw-r--r-- | SmartDeviceLink/SDLMutableDataQueue.m | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/SmartDeviceLink/SDLMutableDataQueue.m b/SmartDeviceLink/SDLMutableDataQueue.m index a2a98f494..0640749b6 100644 --- a/SmartDeviceLink/SDLMutableDataQueue.m +++ b/SmartDeviceLink/SDLMutableDataQueue.m @@ -42,9 +42,9 @@ NS_ASSUME_NONNULL_BEGIN NSMutableData *dataAtFront = nil; @synchronized(self) { - if (self.elements.count) { + if (self.elements.count > 0) { // The front of the queue is always at index 0 - dataAtFront = self.elements[0]; + dataAtFront = self.elements.firstObject; self.frontDequeued = YES; } } @@ -54,6 +54,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)popBuffer { @synchronized(self) { + if (self.elements.count <= 0) { return; } [self.elements removeObjectAtIndex:0]; } } |