cJSON

mirror of Dave's cJSON
git clone git://git.thc420.xyz/cJSON
Log | Files | Refs | README | LICENSE

commit 59cf4112d224722030a4b485fc8bda9778a630ca
parent 624bc85143c90e8e2eaf5f0471942d96157cec8f
Author: Max Bruckner <max@maxbruckner.de>
Date:   Mon, 28 Nov 2016 22:29:03 +0700

Merge pull request #78 from gatzka/feature/gcc_check_strict_overflow_v2

gcc check strict overflow v2
Diffstat:
MCMakeLists.txt | 2+-
MMakefile | 2+-
McJSON.c | 3++-
3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt @@ -15,7 +15,7 @@ set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT option(ENABLE_CUSTOM_COMPILER_FLAGS "Enables custom compiler flags for Clang and GCC" ON) if (ENABLE_CUSTOM_COMPILER_FLAGS) if(("${CMAKE_C_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89 -pedantic -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wshadow -Winit-self -Wcast-align -Wformat=2 -Wmissing-prototypes") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c89 -pedantic -Wall -Wextra -Werror -Wstrict-prototypes -Wwrite-strings -Wshadow -Winit-self -Wcast-align -Wformat=2 -Wmissing-prototypes -Wstrict-overflow=2") endif() endif() diff --git a/Makefile b/Makefile @@ -20,7 +20,7 @@ INSTALL_LIBRARY_PATH = $(DESTDIR)$(PREFIX)/$(LIBRARY_PATH) INSTALL ?= cp -a -R_CFLAGS = -fPIC -std=c89 -pedantic -Wall -Werror -Wstrict-prototypes -Wwrite-strings -Wshadow -Winit-self -Wcast-align -Wformat=2 -Wmissing-prototypes $(CFLAGS) +R_CFLAGS = -fPIC -std=c89 -pedantic -Wall -Werror -Wstrict-prototypes -Wwrite-strings -Wshadow -Winit-self -Wcast-align -Wformat=2 -Wmissing-prototypes -Wstrict-overflow=2 $(CFLAGS) uname := $(shell sh -c 'uname -s 2>/dev/null || echo false') diff --git a/cJSON.c b/cJSON.c @@ -712,8 +712,9 @@ static char *print_string_ptr(const char *str, printbuffer *p) ptr = str; /* calculate additional space that is needed for escaping */ - while ((token = *ptr) && ++len) + while ((token = *ptr)) { + ++len; if (strchr("\"\\\b\f\n\r\t", token)) { len++; /* +1 for the backslash */