From 25d9e28fed6826bd8abda0814dc64ca6cafd16e0 Mon Sep 17 00:00:00 2001 From: mingkuang Date: Wed, 5 Aug 2020 16:21:35 +0800 Subject: [PATCH 1/2] fix CircularBuffer operator=, No explicit return value. --- include/mscomp/CircularBuffer.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/mscomp/CircularBuffer.h b/include/mscomp/CircularBuffer.h index 95ae27e..4638a64 100644 --- a/include/mscomp/CircularBuffer.h +++ b/include/mscomp/CircularBuffer.h @@ -39,6 +39,8 @@ class CircularBuffer memcpy(this->buffer, rhs.buffer, Size); this->tail = this->buffer + (rhs.tail - rhs.buffer); this->full = rhs.full; + + return *this; } INLINE bool empty() const { return UNLIKELY(!this->full && this->tail == this->buffer); } INLINE uint32_t size() const { return LIKELY(this->full) ? Size : (uint32_t)(this->tail - this->buffer); } From ea824c77a497b76688abe0c668a3aaa2f402189d Mon Sep 17 00:00:00 2001 From: mingkuang Date: Wed, 5 Aug 2020 16:29:10 +0800 Subject: [PATCH 2/2] fix SET_ERROR, INIT_STREAM_ERROR_MESSAGE, SET_WARNING, INIT_STREAM_WARNING_MESSAGE maybe Null pointer used. --- include/mscomp/internal.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/mscomp/internal.h b/include/mscomp/internal.h index 3bf4b45..8def5ad 100644 --- a/include/mscomp/internal.h +++ b/include/mscomp/internal.h @@ -454,16 +454,16 @@ typedef const_byte* RESTRICT const_rest_bytes; #endif #ifdef MSCOMP_WITH_ERROR_MESSAGES - #define SET_ERROR(s, ...) snprintf(s->error, ARRAYSIZE(s->error), __VA_ARGS__) - #define INIT_STREAM_ERROR_MESSAGE(s) s->error[0] = 0 + #define SET_ERROR(s, ...) (s ? snprintf(s->error, ARRAYSIZE(s->error), __VA_ARGS__) : -1) + #define INIT_STREAM_ERROR_MESSAGE(s) (s ? s->error[0] = 0 : 0) #else #define SET_ERROR(s, ...) #define INIT_STREAM_ERROR_MESSAGE(s) #endif #ifdef MSCOMP_WITH_WARNING_MESSAGES - #define SET_WARNING(s, ...) snprintf(s->warning, ARRAYSIZE(s->warning), __VA_ARGS__) - #define INIT_STREAM_WARNING_MESSAGE(s) s->warning[0] = 0 + #define SET_WARNING(s, ...) (s ? snprintf(s->warning, ARRAYSIZE(s->warning), __VA_ARGS__) : -1) + #define INIT_STREAM_WARNING_MESSAGE(s) (s ? s->warning[0] = 0 : 0) #else #define SET_WARNING(s, ...) #define INIT_STREAM_WARNING_MESSAGE(s)