Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/gha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
cd ..

# build and test
CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" GTEST_ROOT="${BASE}/usr" CFLAGS="-Werror -g" CXXFLAGS="-Werror -g" ${ACTION}
CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" GTEST_ROOT="${BASE}/usr" CFLAGS="-Werror -g -fsanitize=undefined" CXXFLAGS="-Werror -g -fsanitize=undefined" ${ACTION}

linux:
runs-on: ubuntu-18.04
Expand Down Expand Up @@ -172,7 +172,7 @@ jobs:
fi

# build and test
CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" GTEST_ROOT="${BASE}/usr" CFLAGS="-Werror -g" CXXFLAGS="-Werror -g" MSGPACK_SAN="${SAN}" ${ACTION}
CMAKE_CXX_COMPILER="${CXX}" CMAKE_C_COMPILER="${CC}" GTEST_ROOT="${BASE}/usr" CFLAGS="-Werror -g -fsanitize=undefined" CXXFLAGS="-Werror -g -fsanitize=undefined" MSGPACK_SAN="${SAN}" ${ACTION}

windows:
runs-on: windows-2019
Expand Down
2 changes: 1 addition & 1 deletion ci/build_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ else
export ARCH_FLAG="-m64"
fi

cmake -DMSGPACK_32BIT=${BIT32} -DBUILD_SHARED_LIBS=${SHARED} -DMSGPACK_CHAR_SIGN=${CHAR_SIGN} -DCMAKE_CXX_FLAGS=${ARCH_FLAG} ..
cmake -DMSGPACK_32BIT=${BIT32} -DBUILD_SHARED_LIBS=${SHARED} -DMSGPACK_CHAR_SIGN=${CHAR_SIGN} -DCMAKE_CXX_FLAGS="${ARCH_FLAG} ${CXXFLAGS}" -DCMAKE_C_FLAGS="${CFLAGS}" ..

ret=$?
if [ $ret -ne 0 ]
Expand Down
4 changes: 4 additions & 0 deletions include/msgpack/fbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define MSGPACK_FBUFFER_H

#include <stdio.h>
#include <assert.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -25,6 +26,9 @@ extern "C" {

static inline int msgpack_fbuffer_write(void* data, const char* buf, size_t len)
{
assert(buf || len == 0);
if(!buf) return 0;

return (1 == fwrite(buf, len, 1, (FILE *)data)) ? 0 : -1;
}

Expand Down
9 changes: 5 additions & 4 deletions include/msgpack/sbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ static inline void msgpack_sbuffer_free(msgpack_sbuffer* sbuf)
static inline int msgpack_sbuffer_write(void* data, const char* buf, size_t len)
{
msgpack_sbuffer* sbuf = (msgpack_sbuffer*)data;

assert(buf || len == 0);
if(!buf) return 0;

if(sbuf->alloc - sbuf->size < len) {
void* tmp;
Expand All @@ -83,10 +85,9 @@ static inline int msgpack_sbuffer_write(void* data, const char* buf, size_t len)
sbuf->alloc = nsize;
}

if(buf) {
memcpy(sbuf->data + sbuf->size, buf, len);
sbuf->size += len;
}
memcpy(sbuf->data + sbuf->size, buf, len);
sbuf->size += len;

return 0;
}

Expand Down
4 changes: 4 additions & 0 deletions include/msgpack/vrefbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "zone.h"
#include <stdlib.h>
#include <assert.h>

#if defined(unix) || defined(__unix) || defined(__linux__) || defined(__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__QNX__) || defined(__QNXTO__) || defined(__HAIKU__)
#include <sys/uio.h>
Expand Down Expand Up @@ -114,6 +115,9 @@ static inline void msgpack_vrefbuffer_free(msgpack_vrefbuffer* vbuf)
static inline int msgpack_vrefbuffer_write(void* data, const char* buf, size_t len)
{
msgpack_vrefbuffer* vbuf = (msgpack_vrefbuffer*)data;
assert(buf || len == 0);

if(!buf) return 0;

if(len < vbuf->ref_size) {
return msgpack_vrefbuffer_append_copy(vbuf, buf, len);
Expand Down
4 changes: 4 additions & 0 deletions include/msgpack/zbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "sysdep.h"
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <zlib.h>

#ifdef __cplusplus
Expand Down Expand Up @@ -121,6 +122,9 @@ static inline int msgpack_zbuffer_write(void* data, const char* buf, size_t len)
{
msgpack_zbuffer* zbuf = (msgpack_zbuffer*)data;

assert(buf || len == 0);
if(!buf) return 0;

zbuf->stream.next_in = (Bytef*)buf;
zbuf->stream.avail_in = (uInt)len;

Expand Down