From 3de6274c830e3d2a5ca5e0ab08cdb270583d4d64 Mon Sep 17 00:00:00 2001 From: Dave Schukin Date: Fri, 1 Mar 2019 01:54:07 -0800 Subject: [PATCH] Fix for crasher caused by out of bounds index --- LTSupportAutomotive/LTOBD2ProtocolISO15765_4.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/LTSupportAutomotive/LTOBD2ProtocolISO15765_4.m b/LTSupportAutomotive/LTOBD2ProtocolISO15765_4.m index bc57c1e..8d32b34 100644 --- a/LTSupportAutomotive/LTOBD2ProtocolISO15765_4.m +++ b/LTSupportAutomotive/LTOBD2ProtocolISO15765_4.m @@ -121,6 +121,11 @@ -(instancetype)initWithNumberOfBitsInHeader:(NSUInteger)numberOfBitsInHeader NSUInteger originalCommandCorrective = ( isSingleFrame || isFirstFrameOfMultiple ) ? numberOfBytesInCommand : 0; NSUInteger payloadIndex = headerLength + originalCommandCorrective + multiFrameCorrective; + + if (payloadIndex >= bytesInLine.count) { + continue; + } + NSUInteger payloadLength = bytesInLine.count - payloadIndex; NSRange payloadRange = NSMakeRange(payloadIndex, payloadLength); NSArray* payload = [bytesInLine subarrayWithRange:payloadRange];