Skip to content

Commit 58aae46

Browse files
authored
Fix static analysis issue (#120)
1 parent 84fadf8 commit 58aae46

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,29 @@ void PlatformChannel::HandleMethodCall(
105105
SystemNavigatorPop();
106106
result->Success();
107107
} else if (method == kPlaySoundMethod) {
108+
if (!arguments) {
109+
result->Error("Invalid arguments");
110+
return;
111+
}
108112
PlaySystemSound(arguments[0].GetString());
109113
result->Success();
110114
} else if (method == kHapticFeedbackVibrateMethod) {
111115
std::string type;
116+
if (!arguments) {
117+
result->Error("Invalid arguments");
118+
return;
119+
}
112120
if (arguments->IsString()) {
113121
type = arguments[0].GetString();
114122
}
115123
HapticFeedbackVibrate(type);
116124
result->Success();
117125
} else if (method == kGetClipboardDataMethod) {
126+
if (!arguments) {
127+
result->Error("Invalid arguments");
128+
return;
129+
}
130+
118131
// https://api.flutter.dev/flutter/services/Clipboard/kTextPlain-constant.html
119132
// The API only supports the plain text format.
120133
if (strcmp(arguments[0].GetString(), kTextPlainFormat) != 0) {
@@ -144,6 +157,10 @@ void PlatformChannel::HandleMethodCall(
144157
delete result_ptr;
145158
};
146159
} else if (method == kSetClipboardDataMethod) {
160+
if (!arguments) {
161+
result->Error("Invalid arguments");
162+
return;
163+
}
147164
const rapidjson::Value& document = *arguments;
148165
auto iter = document.FindMember(kTextKey);
149166
if (iter == document.MemberEnd()) {
@@ -160,6 +177,10 @@ void PlatformChannel::HandleMethodCall(
160177
rapidjson::Value(ClipboardHasStrings()), allocator);
161178
result->Success(document);
162179
} else if (method == kExitApplicationMethod) {
180+
if (!arguments) {
181+
result->Error("Invalid arguments");
182+
return;
183+
}
163184
rapidjson::Value::ConstMemberIterator iter =
164185
arguments->FindMember(kExitTypeKey);
165186
if (iter == arguments->MemberEnd()) {
@@ -190,6 +211,10 @@ void PlatformChannel::HandleMethodCall(
190211
RestoreSystemUiOverlays();
191212
result->Success();
192213
} else if (method == kSetEnabledSystemUiOverlaysMethod) {
214+
if (!arguments) {
215+
result->Error("Invalid arguments");
216+
return;
217+
}
193218
const rapidjson::Document& list = arguments[0];
194219
std::vector<std::string> overlays;
195220
for (auto iter = list.Begin(); iter != list.End(); ++iter) {
@@ -198,6 +223,10 @@ void PlatformChannel::HandleMethodCall(
198223
SetEnabledSystemUiOverlays(overlays);
199224
result->Success();
200225
} else if (method == kSetPreferredOrientationsMethod) {
226+
if (!arguments) {
227+
result->Error("Invalid arguments");
228+
return;
229+
}
201230
const rapidjson::Document& list = arguments[0];
202231
std::vector<std::string> orientations;
203232
for (auto iter = list.Begin(); iter != list.End(); ++iter) {

flutter/shell/platform/tizen/tizen_renderer_egl.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ bool TizenRendererEgl::ChooseEGLConfiguration() {
200200
}
201201

202202
EGLConfig* configs = (EGLConfig*)calloc(config_size, sizeof(EGLConfig));
203+
if (!configs) {
204+
FT_LOG(Error) << "Failed to allocate memory for EGL configurations.";
205+
return false;
206+
}
203207
EGLint num_config;
204208
if (enable_impeller_) {
205209
EGLint impeller_config_attribs[] = {

0 commit comments

Comments
 (0)