From 2ee54456bb4dac047215fefc4b7282a4331a506b Mon Sep 17 00:00:00 2001 From: "Byron Campen [:bwc]" Date: Wed, 19 Feb 2014 16:39:07 -0800 Subject: [PATCH] Bug 973315 - Make code that sets PeerConnectionImpl::mName more tolerant of weird scenarios. r=jib --- .../src/peerconnection/PeerConnectionImpl.cpp | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index a632c95c08e..b14b8270974 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -728,22 +728,26 @@ PeerConnectionImpl::Initialize(PeerConnectionObserver& aObserver, char temp[128]; #ifdef MOZILLA_INTERNAL_API - nsIDOMLocation* location = nullptr; - mWindow->GetLocation(&location); - MOZ_ASSERT(location); - nsString locationAStr; - location->ToString(locationAStr); - location->Release(); + nsAutoCString locationCStr; + nsIDOMLocation* location; + res = mWindow->GetLocation(&location); + + if (location && NS_SUCCEEDED(res)) { + nsAutoString locationAStr; + location->ToString(locationAStr); + location->Release(); + + CopyUTF16toUTF8(locationAStr, locationCStr); + } + + PR_snprintf( + temp, + sizeof(temp), + "%llu (id=%llu url=%s)", + static_cast(timestamp), + static_cast(mWindow ? mWindow->WindowID() : 0), + locationCStr.get() ? locationCStr.get() : "NULL"); - nsCString locationCStr; - CopyUTF16toUTF8(locationAStr, locationCStr); - MOZ_ASSERT(mWindow); - PR_snprintf(temp, - sizeof(temp), - "%llu (id=%u url=%s)", - (unsigned long long)timestamp, - (unsigned)mWindow->WindowID(), - locationCStr.get() ? locationCStr.get() : "NULL"); #else PR_snprintf(temp, sizeof(temp), "%llu", (unsigned long long)timestamp); #endif // MOZILLA_INTERNAL_API