Bug 1490700 - Cap capability values to avoid truncation. r=jib
authorAndreas Pehrson <apehrson@mozilla.com>
Fri, 14 Sep 2018 09:15:53 +0000
changeset 436336 55cda0919f07d83f3df21e7c2f48c10ab106e522
parent 436335 53e3ff3c189d4b39f069d62b055a79c4c0b43323
child 436337 619ef3811776b7fd002decd4f5bcbb8810029c66
child 436355 409d6dbcca4699a91109cada1f9ee46cd8d98850
push id34640
push usercbrindusan@mozilla.com
push dateFri, 14 Sep 2018 15:27:56 +0000
treeherdermozilla-central@619ef3811776 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjib
bugs1490700
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1490700 - Cap capability values to avoid truncation. r=jib Differential Revision: https://phabricator.services.mozilla.com/D5785
dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
--- a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
+++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp
@@ -896,19 +896,21 @@ MediaEngineRemoteVideoSource::ChooseCapa
     case MediaSourceEnum::Application: {
       FlattenedConstraints c(aConstraints);
       // The actual resolution to constrain around is not easy to find ahead of
       // time (and may in fact change over time), so as a hack, we push ideal
       // and max constraints down to desktop_capture_impl.cc and finish the
       // algorithm there.
       // TODO: This can be removed in bug 1453269.
       aCapability.width =
-        (c.mWidth.mIdeal.valueOr(0) & 0xffff) << 16 | (c.mWidth.mMax & 0xffff);
+        (std::min(0xffff, c.mWidth.mIdeal.valueOr(0)) & 0xffff) << 16 |
+        (std::min(0xffff, c.mWidth.mMax) & 0xffff);
       aCapability.height =
-        (c.mHeight.mIdeal.valueOr(0) & 0xffff) << 16 | (c.mHeight.mMax & 0xffff);
+        (std::min(0xffff, c.mHeight.mIdeal.valueOr(0)) & 0xffff) << 16 |
+        (std::min(0xffff, c.mHeight.mMax) & 0xffff);
       aCapability.maxFPS =
         c.mFrameRate.Clamp(c.mFrameRate.mIdeal.valueOr(aPrefs.mFPS));
       return true;
     }
     default:
       break;
   }