mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 10:19:20 +00:00
LibWeb: Protect audio codec callbacks against its own destruction
The plugin may go out of scope before the callbacks we've queued have fired. It is undefined behavior for these callbacks to access the plugin data after that has occurred. This patch protects these callbacks with weak pointers. Note that the plugin is not ref-counted, so we cannot use `strong_ref` here.
This commit is contained in:
parent
e011ddd368
commit
9586a7500c
Notes:
github-actions[bot]
2025-03-14 17:03:21 +00:00
Author: https://github.com/trflynn89
Commit: 9586a7500c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3937
2 changed files with 48 additions and 25 deletions
|
@ -10,11 +10,12 @@
|
|||
#include <AK/Function.h>
|
||||
#include <AK/NonnullOwnPtr.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/Weakable.h>
|
||||
#include <LibMedia/Audio/Forward.h>
|
||||
|
||||
namespace Web::Platform {
|
||||
|
||||
class AudioCodecPlugin {
|
||||
class AudioCodecPlugin : public Weakable<AudioCodecPlugin> {
|
||||
public:
|
||||
using AudioCodecPluginCreator = Function<ErrorOr<NonnullOwnPtr<AudioCodecPlugin>>(NonnullRefPtr<Audio::Loader>)>;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue