Skip to content

Commit

Permalink
LibCore: Make EventReceiver ref counting use atomics
Browse files Browse the repository at this point in the history
This removes a race in ImageDecoder's make_decode_image_job(), where the
ref count of `this` is mutated from separate threads in the callbacks.
  • Loading branch information
awesomekling committed Dec 26, 2024
1 parent 3913e9f commit 4eda7b5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Libraries/LibCore/EventReceiver.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*
* Copyright (c) 2018-2021, Andreas Kling <[email protected]>
* Copyright (c) 2018-2024, Andreas Kling <[email protected]>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/

#pragma once

#include <AK/AtomicRefCounted.h>
#include <AK/ByteString.h>
#include <AK/Forward.h>
#include <AK/Function.h>
Expand Down Expand Up @@ -50,7 +51,7 @@ public: \
}

class EventReceiver
: public RefCounted<EventReceiver>
: public AtomicRefCounted<EventReceiver>
, public Weakable<EventReceiver> {
// NOTE: No C_OBJECT macro for Core::EventReceiver itself.

Expand Down

0 comments on commit 4eda7b5

Please sign in to comment.