Skip to content

Commit 7bb8783

Browse files
authored
Fix memory safety issues in AppControlChannel (#151)
1 parent 7dd44fb commit 7bb8783

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

flutter/shell/platform/tizen/channels/app_control.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ AppControl::AppControl(app_control_h handle) : id_(next_id_++) {
6767
}
6868

6969
AppControl::~AppControl() {
70+
on_reply_ = nullptr;
7071
if (handle_) {
7172
app_control_destroy(handle_);
7273
}

flutter/shell/platform/tizen/channels/app_control_channel.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "app_control_channel.h"
66

77
#include <cstdint>
8+
#include <memory>
89
#include <string>
910
#include <variant>
1011
#include <vector>
@@ -169,15 +170,14 @@ void AppControlChannel::SendLaunchRequest(
169170
std::unique_ptr<MethodResult<EncodableValue>> result) {
170171
EncodableValueHolder<bool> wait_for_reply(arguments, "waitForReply");
171172
if (wait_for_reply && *wait_for_reply) {
172-
auto* result_ptr = result.release();
173-
auto on_reply = [result_ptr](const EncodableValue& response) {
174-
result_ptr->Success(response);
175-
delete result_ptr;
173+
std::shared_ptr<MethodResult<EncodableValue>> result_box{std::move(result)};
174+
auto on_reply = [result_box](const EncodableValue& response) {
175+
result_box->Success(response);
176176
};
177+
177178
AppControlResult ret = app_control->SendLaunchRequestWithReply(on_reply);
178179
if (!ret) {
179-
result_ptr->Error(ret.code(), ret.message());
180-
delete result_ptr;
180+
result_box->Error(ret.code(), ret.message());
181181
}
182182
} else {
183183
AppControlResult ret = app_control->SendLaunchRequest();

0 commit comments

Comments
 (0)