Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6f06cf0

Browse filesBrowse files
addaleaxMylesBorins
authored andcommitted
src: delete BaseObjectWeakPtr data when pointee is gone
Fix the condition for deleting the underlying data pointed to by a `BaseObjectWeakPtr`, which erroneously skipped that deletion when `ptr->get()` was `nullptr`. This fixes a memory leak reported by some of the tests. Refs: #30374 (comment) PR-URL: #32393 Reviewed-By: Matheus Marchini <mat@mmarchini.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 2bcf535 commit 6f06cf0
Copy full SHA for 6f06cf0

File tree

Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-3
lines changed
Open diff view settings
Collapse file

‎src/base_object-inl.h‎

Copy file name to clipboardExpand all lines: src/base_object-inl.h
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,13 @@ BaseObject* BaseObjectPtrImpl<T, kIsWeak>::get_base_object() const {
234234

235235
template <typename T, bool kIsWeak>
236236
BaseObjectPtrImpl<T, kIsWeak>::~BaseObjectPtrImpl() {
237-
if (get() == nullptr) return;
238237
if (kIsWeak) {
239-
if (--pointer_data()->weak_ptr_count == 0 &&
238+
if (pointer_data() != nullptr &&
239+
--pointer_data()->weak_ptr_count == 0 &&
240240
pointer_data()->self == nullptr) {
241241
delete pointer_data();
242242
}
243-
} else {
243+
} else if (get() != nullptr) {
244244
get()->decrease_refcount();
245245
}
246246
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.