Browse Source

Merge pull request #389 from besser82/bugfix/invalid_free

json_object: Avoid double free (and thus a segfault) when ref_count gets < 0
tags/json-c-0.14-20200419
Eric Haszlakiewicz GitHub 7 years ago
parent
commit
5ea6a05bfa
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions
  1. +5
    -0
      json_object.c

+ 5
- 0
json_object.c View File

@@ -182,6 +182,11 @@ int json_object_put(struct json_object *jso)
{
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)
/* Note: this only allow the refcount to remain correct
* when multiple threads are adjusting it. It is still an error


Loading…
Cancel
Save