Skip to content
This repository was archived by the owner on Mar 22, 2022. It is now read-only.

Commit c3e1107

Browse files
committed
Fix NULL dereferencing in mrsPeerConnectionCreate
Ensure that mrsPeerConnectionCreate() returns an error code when the internal peer connection implementation object fails to instantiate or initialize, instead of dereferencing it.
1 parent 59c425e commit c3e1107

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

libs/Microsoft.MixedReality.WebRTC.Native/include/peer_connection.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ class PeerConnection : public webrtc::PeerConnectionObserver,
4848
public webrtc::CreateSessionDescriptionObserver {
4949
public:
5050
/// Create a new PeerConnection using the given |factory|, based on the given
51-
/// |config|. This serves as the constructor for PeerConnection.
51+
/// |config|. This serves as the constructor for PeerConnection, and returns a
52+
/// NULL pointer on failure.
5253
static rtc::scoped_refptr<PeerConnection> create(
5354
webrtc::PeerConnectionFactoryInterface& factory,
5455
const webrtc::PeerConnectionInterface::RTCConfiguration& config,

libs/Microsoft.MixedReality.WebRTC.Native/src/interop/interop_api.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,9 @@ mrsPeerConnectionCreate(PeerConnectionConfiguration config,
801801
// Create the new peer connection
802802
rtc::scoped_refptr<PeerConnection> peer =
803803
PeerConnection::create(*factory, rtc_config, interop_handle);
804+
if (!peer) {
805+
return MRS_E_UNKNOWN;
806+
}
804807
const PeerConnectionHandle handle =
805808
g_factory->AddPeerConnection(std::move(peer));
806809

0 commit comments

Comments
 (0)