This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 33bd797bb3086df71f669afae9a67ec4c303e867 Author: dongjiuzhu1 <[email protected]> AuthorDate: Sun May 28 22:10:43 2023 +0800 mm/circbuf: skip buffer content according position in circbuf_peekat The circbuf_peekat should copy valid content from the specfied position of buffer, so skip the area from this position to the tail. Signed-off-by: dongjiuzhu1 <[email protected]> --- mm/circbuf/circbuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/circbuf/circbuf.c b/mm/circbuf/circbuf.c index 165a228f45..b85a029f59 100644 --- a/mm/circbuf/circbuf.c +++ b/mm/circbuf/circbuf.c @@ -301,12 +301,12 @@ ssize_t circbuf_peekat(FAR struct circbuf_s *circ, size_t pos, DEBUGASSERT(circ); - if (!circ->size) + if (!circ->size || pos >= circ->head) { return 0; } - len = circbuf_used(circ); + len = circ->head - pos; off = pos % circ->size; if (bytes > len)
