diff --git a/source/cellular_pktio.c b/source/cellular_pktio.c index eb5925db..6db83687 100644 --- a/source/cellular_pktio.c +++ b/source/cellular_pktio.c @@ -921,10 +921,10 @@ static bool _preprocessInputBuffer( CellularContext_t * pContext, &bufferLength ); PlatformMutex_Unlock( &pContext->PktRespMutex ); - keepProcess = _handleCallbackResult( pContext, pktStatus, pTempLine, pBytesRead ); - if( pktStatus == CELLULAR_PKT_STATUS_OK ) { + /* Handle the callback result is CELLULAR_PKT_STATUS_OK in this function. + * Check the bufferLength returned by callback function here. */ if( bufferLength > *pBytesRead ) { /* The input buffer callback returns incorrect buffer length. */ @@ -950,6 +950,10 @@ static bool _preprocessInputBuffer( CellularContext_t * pContext, *pBytesRead = *pBytesRead - bufferLength; } } + else + { + keepProcess = _handleCallbackResult( pContext, pktStatus, pTempLine, pBytesRead ); + } } return keepProcess;