aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/ref_counted.h5
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();