[thanos] Fixed UAF in allDone callback via weak_ptr guard.

This commit is contained in:
23rd
2026-05-22 10:28:37 +03:00
parent fce7ac6277
commit 4b3cb4f0fe
2 changed files with 8 additions and 5 deletions
@@ -151,10 +151,12 @@ void ThanosEffect::ensureSurface() {
std::move(devicePixelRatio));
_renderer = renderer.get();
_renderer->allDone() | rpl::on_next([=] {
crl::on_main(_parent, [=] {
hideSurface();
_allDone.fire({});
_renderer->allDone() | rpl::on_next([weak = base::make_weak(this)] {
crl::on_main(weak, [weak] {
if (const auto strong = weak.get()) {
strong->hideSurface();
strong->_allDone.fire({});
}
});
}, _lifetime);
@@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#pragma once
#include "base/unique_qptr.h"
#include "base/weak_ptr.h"
#include <QImage>
@@ -20,7 +21,7 @@ namespace Ui {
class ThanosEffectRenderer;
class ThanosEffect final {
class ThanosEffect final : public base::has_weak_ptr {
public:
explicit ThanosEffect(not_null<QWidget*> parent);
~ThanosEffect();