提交 c2168cf9 编写于 作者: J jp9000

libobs/util: Don't perform calculation until data checked

上级 c6914fda
......@@ -192,12 +192,11 @@ static inline void circlebuf_push_front(struct circlebuf *cb, const void *data,
static inline void circlebuf_peek_front(struct circlebuf *cb, void *data,
size_t size)
{
size_t start_size;
assert(size <= cb->size);
start_size = cb->capacity - cb->start_pos;
if (data) {
size_t start_size = cb->capacity - cb->start_pos;
if (start_size < size) {
memcpy(data, (uint8_t*)cb->data + cb->start_pos,
start_size);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册