Bug 1448208: Use CheckedInt for overflow check in nsWindowWatcher::SizeOpenedWindow. r=froydnj

--HG--
extra : rebase_source : 5781b2086ee7af0b211fb28d2fda02f433ecbbca
This commit is contained in:
David Major 2018-03-23 13:02:49 -04:00
Родитель 750b04b27f
Коммит 198ddd8ab8
2 изменённых файлов: 11 добавлений и 4 удалений

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

@ -9,6 +9,5 @@ skip-if = (toolkit == "cocoa" && e10s) # bug 1252223
[test_private_window_from_content.html]
[test_window_open_position_constraint.html]
skip-if = toolkit == 'android'
fail-if = (os == "win" && ccov) # bug 1421715
[test_window_open_units.html]
skip-if = toolkit == 'android'

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

@ -59,6 +59,7 @@
#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
#include "nsSandboxFlags.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/Preferences.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/Storage.h"
@ -2368,19 +2369,26 @@ nsWindowWatcher::SizeOpenedWindow(nsIDocShellTreeOwner* aTreeOwner,
}
}
if (left + winWidth > screenLeft + screenWidth ||
left + winWidth < left) {
CheckedInt<decltype(left)> leftPlusWinWidth = left;
leftPlusWinWidth += winWidth;
if (!leftPlusWinWidth.isValid() ||
leftPlusWinWidth.value() > screenLeft + screenWidth) {
left = screenLeft + screenWidth - winWidth;
}
if (left < screenLeft) {
left = screenLeft;
}
if (top + winHeight > screenTop + screenHeight || top + winHeight < top) {
CheckedInt<decltype(top)> topPlusWinHeight = top;
topPlusWinHeight += winHeight;
if (!topPlusWinHeight.isValid() ||
topPlusWinHeight.value() > screenTop + screenHeight) {
top = screenTop + screenHeight - winHeight;
}
if (top < screenTop) {
top = screenTop;
}
if (top != oldTop || left != oldLeft) {
positionSpecified = true;
}