mirror of
https://github.com/json-c/json-c.git
synced 2026-04-07 14:29:06 +08:00
Merge pull request #392 from besser82/json-c-0.13
json_object: Avoid invalid free (and thus a segfault) when ref_count gets < 0
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
ACLOCAL_AMFLAGS = -I autoconf-archive/m4
|
||||||
|
|
||||||
EXTRA_DIST = README.md README.html
|
EXTRA_DIST = README.md README.html
|
||||||
EXTRA_DIST += config.h.win32
|
EXTRA_DIST += config.h.win32
|
||||||
EXTRA_DIST += Doxyfile
|
EXTRA_DIST += Doxyfile
|
||||||
|
|||||||
@@ -182,6 +182,11 @@ int json_object_put(struct json_object *jso)
|
|||||||
{
|
{
|
||||||
if(!jso) return 0;
|
if(!jso) return 0;
|
||||||
|
|
||||||
|
/* Avoid invalid free and crash explicitly instead of (silently)
|
||||||
|
* segfaulting.
|
||||||
|
*/
|
||||||
|
assert(jso->_ref_count > 0);
|
||||||
|
|
||||||
#if defined(HAVE_ATOMIC_BUILTINS) && defined(ENABLE_THREADING)
|
#if defined(HAVE_ATOMIC_BUILTINS) && defined(ENABLE_THREADING)
|
||||||
/* Note: this only allow the refcount to remain correct
|
/* Note: this only allow the refcount to remain correct
|
||||||
* when multiple threads are adjusting it. It is still an error
|
* when multiple threads are adjusting it. It is still an error
|
||||||
|
|||||||
Reference in New Issue
Block a user