From 5b31545970ab395fcada828a71f7b67e5c39e9a3 Mon Sep 17 00:00:00 2001 From: tangyuxin <462747508@qq.com> Date: Sun, 25 Mar 2018 07:54:25 +0800 Subject: [PATCH] [drivers]Fix put_force bug --- components/drivers/src/ringbuffer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/drivers/src/ringbuffer.c b/components/drivers/src/ringbuffer.c index baeeea0e50..48bf590f8c 100644 --- a/components/drivers/src/ringbuffer.c +++ b/components/drivers/src/ringbuffer.c @@ -119,8 +119,11 @@ rt_size_t rt_ringbuffer_put_force(struct rt_ringbuffer *rb, space_length = rt_ringbuffer_space_len(rb); - if (length > space_length) + if (length > rb->buffer_size) + { + ptr = &ptr[length - rb->buffer_size]; length = rb->buffer_size; + } if (rb->buffer_size - rb->write_index > length) {