diff --git a/components/esp_ringbuf/ringbuf.c b/components/esp_ringbuf/ringbuf.c index 25dd75667a..8c44e0d35d 100644 --- a/components/esp_ringbuf/ringbuf.c +++ b/components/esp_ringbuf/ringbuf.c @@ -831,7 +831,7 @@ static BaseType_t prvReceiveGeneric(Ringbuffer_t *pxRingbuffer, #ifdef __clang_analyzer__ // Teach clang-tidy that if NULL pointers are provided, this function will never dereference them - if (!pvItem1 || !pvItem2 || !xItemSize1 || !xItemSize2) { + if (!pvItem1 || !xItemSize1) { return pdFALSE; } #endif /*__clang_analyzer__ */ @@ -850,6 +850,12 @@ static BaseType_t prvReceiveGeneric(Ringbuffer_t *pxRingbuffer, } //If split buffer, check for split items if (pxRingbuffer->uxRingbufferFlags & rbALLOW_SPLIT_FLAG) { +#ifdef __clang_analyzer__ + // Teach clang-tidy that if NULL pointers are provided, this function will never dereference them + if (!pvItem2 || !xItemSize2) { + return pdFALSE; + } +#endif /*__clang_analyzer__ */ if (xIsSplit == pdTRUE) { *pvItem2 = pxRingbuffer->pvGetItem(pxRingbuffer, &xIsSplit, 0, xItemSize2); configASSERT(*pvItem2 < *pvItem1); //Check wrap around has occurred @@ -897,7 +903,7 @@ static BaseType_t prvReceiveGenericFromISR(Ringbuffer_t *pxRingbuffer, #ifdef __clang_analyzer__ // Teach clang-tidy that if NULL pointers are provided, this function will never dereference them - if (!pvItem1 || !pvItem2 || !xItemSize1 || !xItemSize2) { + if (!pvItem1 || !xItemSize1) { return pdFALSE; } #endif /*__clang_analyzer__ */ @@ -914,6 +920,12 @@ static BaseType_t prvReceiveGenericFromISR(Ringbuffer_t *pxRingbuffer, } //If split buffer, check for split items if (pxRingbuffer->uxRingbufferFlags & rbALLOW_SPLIT_FLAG) { +#ifdef __clang_analyzer__ + // Teach clang-tidy that if NULL pointers are provided, this function will never dereference them + if (!pvItem2 || !xItemSize2) { + return pdFALSE; + } +#endif /*__clang_analyzer__ */ if (xIsSplit == pdTRUE) { *pvItem2 = pxRingbuffer->pvGetItem(pxRingbuffer, &xIsSplit, 0, xItemSize2); configASSERT(*pvItem2 < *pvItem1); //Check wrap around has occurred