mirror of
https://github.com/Qz3rK/tdesktop.git
synced 2026-06-02 03:53:42 +02:00
[thanos] Fixed UAF in allDone callback via weak_ptr guard.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user