From f2a27391d8b70e8e1c4a2b3df19cfda8a5b087ff Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 28 Oct 2016 17:27:09 -0400 Subject: [PATCH] Validate ref count opt-in in bt_ref_get MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- include/babeltrace/ref-internal.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/include/babeltrace/ref-internal.h b/include/babeltrace/ref-internal.h index 8578de97b..3a8b39f41 100644 --- a/include/babeltrace/ref-internal.h +++ b/include/babeltrace/ref-internal.h @@ -50,9 +50,12 @@ static inline void bt_ref_get(struct bt_ref *ref) { assert(ref); - ref->count++; - /* Overflow check. */ - assert(ref->count); + if (ref->release) { + /* Object has opted-in reference counting. */ + ref->count++; + /* Overflow check. */ + assert(ref->count); + } } static inline -- 2.34.1