Bug 1832176: Fix bug where we could set mPendingRidChangeFromCompatMode without setting mPendingParameters. r=jib

This could cause a crash if the timing was just right.

Depends on D177647

Differential Revision: https://phabricator.services.mozilla.com/D177648
This commit is contained in:
Byron Campen 2023-05-26 16:57:25 +00:00
Родитель 3293e5c9b5
Коммит faf76ab127
1 изменённых файлов: 3 добавлений и 1 удалений

Просмотреть файл

@ -575,6 +575,7 @@ already_AddRefed<Promise> RTCRtpSender::SetParameters(
// If any of the following conditions are met,
// return a promise rejected with a newly created InvalidModificationError:
bool pendingRidChangeFromCompatMode = false;
// encodings.length is different from N.
if (paramsCopy.mEncodings.Length() != oldParams->mEncodings.Length()) {
nsCString error("Cannot change the number of encodings with setParameters");
@ -589,7 +590,7 @@ already_AddRefed<Promise> RTCRtpSender::SetParameters(
}
// Make sure we don't use the old rids in SyncToJsep while we wait for the
// queued task below to update mParameters.
mPendingRidChangeFromCompatMode = true;
pendingRidChangeFromCompatMode = true;
mSimulcastEnvelopeSet = true;
if (!mHaveWarnedBecauseEncodingCountChange) {
mHaveWarnedBecauseEncodingCountChange = true;
@ -743,6 +744,7 @@ already_AddRefed<Promise> RTCRtpSender::SetParameters(
// This also allows PeerConnectionImpl to detect when there is a pending
// setParameters, which has implcations for the handling of
// setRemoteDescription.
mPendingRidChangeFromCompatMode = pendingRidChangeFromCompatMode;
mPendingParameters = Some(paramsCopy);
uint32_t serialNumber = ++mNumSetParametersCalls;
MaybeUpdateConduit();