diff options
author | Frank Elias <69520919+FrankElias77@users.noreply.github.com> | 2022-10-21 11:46:28 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-21 11:46:28 -0400 |
commit | 11848426fefd96c8ba5b80f75fcdcc6ab18f890d (patch) | |
tree | 10fe6dedc3501d741dc8e2607cc2385439b60af5 | |
parent | 7c031cb1a616cd361076368af18e6dd2bcdf6129 (diff) | |
parent | bb34d61e2f4cf2d277b9ceb094bd6b0e62786326 (diff) | |
download | sdl_ios-11848426fefd96c8ba5b80f75fcdcc6ab18f890d.tar.gz |
Merge pull request #2113 from smartdevicelink/bugfix/issue-2112-iap-range-error7.6.0-rc.2
Fix iAP write data range error
-rw-r--r-- | SmartDeviceLink/private/SDLIAPDataSession.m | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/SmartDeviceLink/private/SDLIAPDataSession.m b/SmartDeviceLink/private/SDLIAPDataSession.m index 06d2e1f1d..be8b8cfbb 100644 --- a/SmartDeviceLink/private/SDLIAPDataSession.m +++ b/SmartDeviceLink/private/SDLIAPDataSession.m @@ -58,10 +58,14 @@ NS_ASSUME_NONNULL_BEGIN if (bytesWritten >= 0) { if (bytesWritten == bytesRemaining) { [self.sendDataQueue popBuffer]; - } else { + } else if (bytesRemaining > bytesWritten) { // Cleave the sent bytes from the data, the remainder will sit at the head of the queue SDLLogV(@"SDLIAPDataSession writeDataToSessionStream bytes written %ld", (long)bytesWritten); [remainder replaceBytesInRange:NSMakeRange(0, (NSUInteger)bytesWritten) withBytes:NULL length:0]; + } else { + // Error processing current data. Remove corrupted buffer + SDLLogE(@"Unable to remove sent bytes. Bytes remaining is less than bytes written %lu < %lu. Clearing buffer", bytesRemaining, bytesWritten); + [self.sendDataQueue popBuffer]; } } else { // The write operation failed but there is no further information about the error. This can occur when disconnecting from an external accessory. |