diff options
author | HÃ¥vard Pettersen <3535158+havardpe@users.noreply.github.com> | 2023-03-15 13:26:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-15 13:26:04 +0100 |
commit | 33118797862c2025aeafdf11422754e6df4396fc (patch) | |
tree | c5441b39a4e46091c7079a8b66b9ad0e652e3a81 | |
parent | e54a7a0bb3470adb1cfb373c348c43da6d79e239 (diff) | |
parent | 3233635004bb5d71aad41f1be85a0186bb22575d (diff) |
Merge pull request #26448 from vespa-engine/havardpe/verify-object-on-attach
verify object when attaching it to a handle
-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(); |