diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2026-06-14 15:29:19 +0200 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2026-06-14 15:29:19 +0200 |
| commit | 672ed2067f48f3a1d6d6f8a6f97c4e76cc664bc3 (patch) | |
| tree | a25e38cc3b7d7afb4494f0d01429e544d6ee610d /libs/kstd | |
| parent | dcfb1f3eb161c1e096626894667dfd2248893f7d (diff) | |
| download | kernel-672ed2067f48f3a1d6d6f8a6f97c4e76cc664bc3.tar.xz kernel-672ed2067f48f3a1d6d6f8a6f97c4e76cc664bc3.zip | |
kstd/memory: fix self-referential shared_ptr deallocation
Diffstat (limited to 'libs/kstd')
| -rw-r--r-- | libs/kstd/kstd/bits/shared_ptr.hpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/libs/kstd/kstd/bits/shared_ptr.hpp b/libs/kstd/kstd/bits/shared_ptr.hpp index 8930095..57a89c0 100644 --- a/libs/kstd/kstd/bits/shared_ptr.hpp +++ b/libs/kstd/kstd/bits/shared_ptr.hpp @@ -21,7 +21,7 @@ namespace kstd std::atomic<std::size_t> shared_count; std::atomic<std::size_t> weak_count; - explicit shared_control_block(std::size_t shared = 1, std::size_t weak = 0) + explicit shared_control_block(std::size_t shared = 1, std::size_t weak = 1) : shared_count(shared) , weak_count(weak) {} @@ -146,7 +146,7 @@ namespace kstd { if (control != nullptr) { - if (--(control->weak_count) == 0 && control->shared_count == 0) + if (--(control->weak_count) == 0) { delete control; } @@ -579,7 +579,7 @@ namespace kstd delete pointer; pointer = nullptr; - if (control->weak_count == 0) + if (--(control->weak_count) == 0) { delete control; } |
