fix: crash on invalid zoomFactor (#22708)

This commit is contained in:
Shelley Vohr
2020-03-17 08:43:06 -07:00
committed by GitHub
parent bcb1d529ff
commit b798e1ff54
6 changed files with 37 additions and 6 deletions

View File

@@ -2,6 +2,7 @@
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include <limits>
#include <memory>
#include <string>
#include <utility>
@@ -275,7 +276,14 @@ double GetZoomLevel(v8::Local<v8::Value> window) {
return result;
}
void SetZoomFactor(v8::Local<v8::Value> window, double factor) {
void SetZoomFactor(gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> window,
double factor) {
if (factor < std::numeric_limits<double>::epsilon()) {
thrower.ThrowError("'zoomFactor' must be a double greater than 0.0");
return;
}
SetZoomLevel(window, blink::PageZoomFactorToZoomLevel(factor));
}