diff options
author | Håvard Pettersen <havardpe@yahooinc.com> | 2023-03-15 11:09:51 +0000 |
---|---|---|
committer | Håvard Pettersen <havardpe@yahooinc.com> | 2023-03-15 11:09:51 +0000 |
commit | 3233635004bb5d71aad41f1be85a0186bb22575d (patch) | |
tree | 0d49cdb5ba099e38592840ff796f3243a3fb8d41 /vespalib | |
parent | 772568949a67767f06784e8e9350c487f36bf2e2 (diff) |
verify object when attaching it to a handle
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/ref_counted.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/vespalib/src/vespa/vespalib/util/ref_counted.h b/vespalib/src/vespa/vespalib/util/ref_counted.h index 5b1e1b66407..a65cedf365d 100644 --- a/vespalib/src/vespa/vespalib/util/ref_counted.h +++ b/vespalib/src/vespa/vespalib/util/ref_counted.h @@ -53,7 +53,10 @@ class ref_counted template <typename X> friend class ref_counted; private: T *_ptr; - ref_counted(T *ptr) noexcept : _ptr(ptr) {} + ref_counted(T *ptr) noexcept : _ptr(ptr) { + // verify that ptr points to a valid object + (void) ptr->count_refs(); + } void maybe_subref() noexcept { if (_ptr) [[likely]] { _ptr->internal_subref(); |