Compare commits

...

7 Commits

Author SHA1 Message Date
Max Bruckner
86234db095 Release cJSON v1.7.7 2018-05-21 22:08:21 +02:00
Max Bruckner
af5b4911de Fix memory leak if realloc returns NULL
Thanks @AlfieDeng for reporting
2018-05-21 22:00:07 +02:00
Max Bruckner
787d651e81 Contributors: Add Zhao Zhixu 2018-05-08 21:33:33 +02:00
Max Bruckner
1571a3ebe4 Merge pull request #266 from zhaozhixu/master
fix a typo in cJSON.h
2018-05-08 21:31:00 +02:00
Zhao Zhixu
0d5ecc11b6 fix typo 2018-05-08 22:45:14 +08:00
Max Bruckner
529ec06abb Makefile: Fix #263, use $(CC) instead of 'gcc' for detecting the version 2018-04-29 09:20:08 +02:00
Max Bruckner
3349978268 cJSON.c: Remove unnecessary include of float.h, fix #259 2018-04-26 23:58:51 +02:00
6 changed files with 15 additions and 8 deletions

View File

@@ -1,3 +1,10 @@
1.7.7
=====
Fixes:
------
* Fix a memory leak when realloc fails (see #267), thanks @AlfieDeng for reporting
* Fix a typo in the header file (see #266), thanks @zhaozhixu
1.7.6 1.7.6
===== =====
Fixes: Fixes:

View File

@@ -7,7 +7,7 @@ include(GNUInstallDirs)
set(PROJECT_VERSION_MAJOR 1) set(PROJECT_VERSION_MAJOR 1)
set(PROJECT_VERSION_MINOR 7) set(PROJECT_VERSION_MINOR 7)
set(PROJECT_VERSION_PATCH 6) set(PROJECT_VERSION_PATCH 7)
set(CJSON_VERSION_SO 1) set(CJSON_VERSION_SO 1)
set(CJSON_UTILS_VERSION_SO 1) set(CJSON_UTILS_VERSION_SO 1)
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")

View File

@@ -41,6 +41,7 @@ Current Maintainer: [Max Bruckner](https://github.com/FSMaxB)
* [Stephan Gatzka](https://github.com/gatzka) * [Stephan Gatzka](https://github.com/gatzka)
* [Weston Schmidt](https://github.com/schmidtw) * [Weston Schmidt](https://github.com/schmidtw)
* [yangfl](https://github.com/yangfl) * [yangfl](https://github.com/yangfl)
* [Zhao Zhixu](https://github.com/zhaozhixu)
And probably more people on [SourceForge](https://sourceforge.net/p/cjson/bugs/search/?q=status%3Aclosed-rejected+or+status%3Aclosed-out-of-date+or+status%3Awont-fix+or+status%3Aclosed-fixed+or+status%3Aclosed&page=0) And probably more people on [SourceForge](https://sourceforge.net/p/cjson/bugs/search/?q=status%3Aclosed-rejected+or+status%3Aclosed-out-of-date+or+status%3Awont-fix+or+status%3Aclosed-fixed+or+status%3Aclosed&page=0)

View File

@@ -8,7 +8,7 @@ CJSON_TEST_SRC = cJSON.c test.c
LDLIBS = -lm LDLIBS = -lm
LIBVERSION = 1.7.6 LIBVERSION = 1.7.7
CJSON_SOVERSION = 1 CJSON_SOVERSION = 1
UTILS_SOVERSION = 1 UTILS_SOVERSION = 1
@@ -26,7 +26,7 @@ INSTALL ?= cp -a
# validate gcc version for use fstack-protector-strong # validate gcc version for use fstack-protector-strong
MIN_GCC_VERSION = "4.9" MIN_GCC_VERSION = "4.9"
GCC_VERSION := "`gcc -dumpversion`" GCC_VERSION := "`$(CC) -dumpversion`"
IS_GCC_ABOVE_MIN_VERSION := $(shell expr "$(GCC_VERSION)" ">=" "$(MIN_GCC_VERSION)") IS_GCC_ABOVE_MIN_VERSION := $(shell expr "$(GCC_VERSION)" ">=" "$(MIN_GCC_VERSION)")
ifeq "$(IS_GCC_ABOVE_MIN_VERSION)" "1" ifeq "$(IS_GCC_ABOVE_MIN_VERSION)" "1"
CFLAGS += -fstack-protector-strong CFLAGS += -fstack-protector-strong

View File

@@ -41,7 +41,6 @@
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include <stdlib.h> #include <stdlib.h>
#include <float.h>
#include <limits.h> #include <limits.h>
#include <ctype.h> #include <ctype.h>
@@ -82,7 +81,7 @@ CJSON_PUBLIC(char *) cJSON_GetStringValue(cJSON *item) {
} }
/* This is a safeguard to prevent copy-pasters from using incompatible C and header files */ /* This is a safeguard to prevent copy-pasters from using incompatible C and header files */
#if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 6) #if (CJSON_VERSION_MAJOR != 1) || (CJSON_VERSION_MINOR != 7) || (CJSON_VERSION_PATCH != 7)
#error cJSON.h and cJSON.c have different versions. Make sure that both have the same. #error cJSON.h and cJSON.c have different versions. Make sure that both have the same.
#endif #endif
@@ -1114,10 +1113,10 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
if (hooks->reallocate != NULL) if (hooks->reallocate != NULL)
{ {
printed = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->offset + 1); printed = (unsigned char*) hooks->reallocate(buffer->buffer, buffer->offset + 1);
buffer->buffer = NULL;
if (printed == NULL) { if (printed == NULL) {
goto fail; goto fail;
} }
buffer->buffer = NULL;
} }
else /* otherwise copy the JSON over to a new buffer */ else /* otherwise copy the JSON over to a new buffer */
{ {

View File

@@ -31,7 +31,7 @@ extern "C"
/* project version */ /* project version */
#define CJSON_VERSION_MAJOR 1 #define CJSON_VERSION_MAJOR 1
#define CJSON_VERSION_MINOR 7 #define CJSON_VERSION_MINOR 7
#define CJSON_VERSION_PATCH 6 #define CJSON_VERSION_PATCH 7
#include <stddef.h> #include <stddef.h>
@@ -156,7 +156,7 @@ CJSON_PUBLIC(void) cJSON_Delete(cJSON *c);
/* Returns the number of items in an array (or object). */ /* Returns the number of items in an array (or object). */
CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array); CJSON_PUBLIC(int) cJSON_GetArraySize(const cJSON *array);
/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */ /* Retrieve item number "index" from array "array". Returns NULL if unsuccessful. */
CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index); CJSON_PUBLIC(cJSON *) cJSON_GetArrayItem(const cJSON *array, int index);
/* Get item "string" from object. Case insensitive. */ /* Get item "string" from object. Case insensitive. */
CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string); CJSON_PUBLIC(cJSON *) cJSON_GetObjectItem(const cJSON * const object, const char * const string);