Skip to content

Commit

Permalink
Update libwebrtc library and avoid crash if candidate or session desc…
Browse files Browse the repository at this point in the history
…ription is invalid.

  * libwertc has add null check for invalid candidate and session description.
  * Add null check for candidate and session description in flutter_webrtc plugin.
  • Loading branch information
wanchao-xu committed Nov 16, 2023
1 parent cfdfa4c commit 60f17a5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
Binary file modified packages/flutter_webrtc/tizen/lib/aarch64/libwebrtc.so
Binary file not shown.
Binary file modified packages/flutter_webrtc/tizen/lib/armel/libwebrtc.so
Binary file not shown.
Binary file modified packages/flutter_webrtc/tizen/lib/i586/libwebrtc.so
Binary file not shown.
18 changes: 15 additions & 3 deletions packages/flutter_webrtc/tizen/src/flutter_webrtc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,11 @@ void FlutterWebRTC::HandleMethodCall(
findString(constraints, "sdp").c_str(),
&error);

SetLocalDescription(description.get(), pc, std::move(result));
if (description.get() != nullptr) {
SetLocalDescription(description.get(), pc, std::move(result));
} else {
result->Error("setLocalDescriptionFailed", "Invalid type or sdp");
}
} else if (method_call.method_name().compare("setRemoteDescription") == 0) {
if (!method_call.arguments()) {
result->Error("Bad Arguments", "Null constraints arguments received");
Expand All @@ -245,7 +249,11 @@ void FlutterWebRTC::HandleMethodCall(
findString(constraints, "sdp").c_str(),
&error);

SetRemoteDescription(description.get(), pc, std::move(result));
if (description.get() != nullptr) {
SetRemoteDescription(description.get(), pc, std::move(result));
} else {
result->Error("setRemoteDescriptionFailed", "Invalid type or sdp");
}
} else if (method_call.method_name().compare("addCandidate") == 0) {
if (!method_call.arguments()) {
result->Error("Bad Arguments", "Null constraints arguments received");
Expand Down Expand Up @@ -275,7 +283,11 @@ void FlutterWebRTC::HandleMethodCall(
candidate.c_str(), findString(constraints, "sdpMid").c_str(),
sdpMLineIndex == -1 ? 0 : sdpMLineIndex, &error);

AddIceCandidate(rtc_candidate.get(), pc, std::move(result));
if (rtc_candidate.get() != nullptr) {
AddIceCandidate(rtc_candidate.get(), pc, std::move(result));
} else {
result->Error("addCandidateFailed", "Invalid candidate");
}
} else if (method_call.method_name().compare("getStats") == 0) {
if (!method_call.arguments()) {
result->Error("Bad Arguments", "Null constraints arguments received");
Expand Down

0 comments on commit 60f17a5

Please sign in to comment.