From 99ea93338d6eb41e5d61fc3cb3955dfd936b0bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= Date: Wed, 13 Dec 2017 19:22:52 +0100 Subject: [PATCH 1/2] json_object: Avoid invalid free (and thus a segfault) when ref_count gets < 0 --- json_object.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/json_object.c b/json_object.c index 042477a..7c7438d 100644 --- a/json_object.c +++ b/json_object.c @@ -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 From 3e892784762966617e152b43cec110f1178d808c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= Date: Sun, 10 Dec 2017 16:29:41 +0100 Subject: [PATCH 2/2] Makefile: Add ACLOCAL_AMFLAGS This is recommended by the libtool manual. --- Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile.am b/Makefile.am index 7e42185..e1afba5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,5 @@ +ACLOCAL_AMFLAGS = -I autoconf-archive/m4 + EXTRA_DIST = README.md README.html EXTRA_DIST += config.h.win32 EXTRA_DIST += Doxyfile