[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:
Jason Simmons
2023-04-12 08:15:55 -07:00
committed by GitHub
parent bbca9aeb24
commit 847d84fb81
2 changed files with 9 additions and 4 deletions

View File

@@ -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.";
});
}

View File

@@ -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;