[Impeller] Keep a reference to BlitPassGLES in the EncodeCommands lambda to prevent use-after-free (flutter/engine#41100)
[Impeller] Keep a reference to BlitPassGLES in the EncodeCommands lambda to prevent use-after-free
This commit is contained in:
@@ -86,10 +86,12 @@ bool BlitPassGLES::EncodeCommands(
|
||||
return true;
|
||||
}
|
||||
|
||||
return reactor_->AddOperation([transients_allocator, &commands = commands_,
|
||||
std::shared_ptr<const BlitPassGLES> shared_this = shared_from_this();
|
||||
return reactor_->AddOperation([transients_allocator,
|
||||
blit_pass = std::move(shared_this),
|
||||
label = label_](const auto& reactor) {
|
||||
auto result =
|
||||
EncodeCommandsInReactor(transients_allocator, reactor, commands, label);
|
||||
auto result = EncodeCommandsInReactor(transients_allocator, reactor,
|
||||
blit_pass->commands_, label);
|
||||
FML_CHECK(result) << "Must be able to encode GL commands without error.";
|
||||
});
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "flutter/fml/macros.h"
|
||||
#include "flutter/impeller/base/config.h"
|
||||
#include "flutter/impeller/renderer/backend/gles/reactor_gles.h"
|
||||
@@ -12,7 +14,8 @@
|
||||
|
||||
namespace impeller {
|
||||
|
||||
class BlitPassGLES final : public BlitPass {
|
||||
class BlitPassGLES final : public BlitPass,
|
||||
public std::enable_shared_from_this<BlitPassGLES> {
|
||||
public:
|
||||
// |BlitPass|
|
||||
~BlitPassGLES() override;
|
||||
|
||||
Reference in New Issue
Block a user