lib: os: spsc_pbuf: Fix free space calculation Fixing bug in free space calculation which was assuming 1 byte padding and not 32 bit word padding. Bug could result in the data corruption in certain scenario. Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
diff --git a/lib/os/spsc_pbuf.c b/lib/os/spsc_pbuf.c index f58ad90..967869f 100644 --- a/lib/os/spsc_pbuf.c +++ b/lib/os/spsc_pbuf.c
@@ -184,7 +184,7 @@ } } } else { - free_space = rd_idx - wr_idx - 1; + free_space = rd_idx - wr_idx - sizeof(uint32_t); } len = MIN(len, MAX(free_space - (int32_t)LEN_SZ, 0));