aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@ost.ch>2026-06-14 15:43:44 +0200
committerFelix Morgner <felix.morgner@ost.ch>2026-06-14 15:43:44 +0200
commitdbd599ec79e26e9e726afdde19b3aa6ca7648cda (patch)
treea25e38cc3b7d7afb4494f0d01429e544d6ee610d /libs
parentdd6537650ca7446a30b54aced340e17ad1b19f10 (diff)
parent672ed2067f48f3a1d6d6f8a6f97c4e76cc664bc3 (diff)
downloadkernel-dbd599ec79e26e9e726afdde19b3aa6ca7648cda.tar.xz
kernel-dbd599ec79e26e9e726afdde19b3aa6ca7648cda.zip
Merge branch 'fmorgner/develop/fix-shared-ptr-leaks' into 'develop'
Fix kstd::shared_ptr based leaks (and potential double-frees) See merge request teachos/kernel!51
Diffstat (limited to 'libs')
-rw-r--r--libs/kstd/kstd/bits/shared_ptr.hpp6
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;
}