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>
This commit is contained in:
parent
a0a8a12642
commit
09b41829a8
1 changed files with 1 additions and 1 deletions
|
@ -184,7 +184,7 @@ int spsc_pbuf_alloc(struct spsc_pbuf *pb, uint16_t len, char **buf)
|
|||
}
|
||||
}
|
||||
} 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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue