Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Unified Diff: chrome/renderer/resources/json_schema.js

Issue 5018002: Fixes a crash when entering a negative index with chrome.tabs.move .... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/tabs/basics/move.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/resources/json_schema.js
===================================================================
--- chrome/renderer/resources/json_schema.js (revision 65777)
+++ chrome/renderer/resources/json_schema.js (working copy)
@@ -105,7 +105,7 @@
*/
chromeHidden.JSONSchemaValidator.getType = function(value) {
var s = typeof value;
-
+ var maxInt = -1 >>> 1;
Aaron Boodman 2010/11/18 23:04:35 This is not the largest representable integer in J
if (s == "object") {
if (value === null) {
return "null";
@@ -114,7 +114,7 @@
return "array";
}
} else if (s == "number") {
- if (value % 1 == 0) {
+ if ((value % 1 == 0) && (Math.abs(value) <= maxInt)) {
return "integer";
}
}
@@ -380,10 +380,10 @@
*/
chromeHidden.JSONSchemaValidator.prototype.validateString = function(
instance, schema, path) {
- if (schema.minLength && instance.length < schema.minLength)
+ if ('minLength' in schema && instance.length < schema.minLength)
this.addError(path, "stringMinLength", [schema.minLength]);
- if (schema.maxLength && instance.length > schema.maxLength)
+ if ('maxLength' in schema && instance.length > schema.maxLength)
this.addError(path, "stringMaxLength", [schema.maxLength]);
if (schema.pattern && !schema.pattern.test(instance))
@@ -405,10 +405,10 @@
instance == Number.NEGATIVE_INFINITY )
this.addError(path, "numberFiniteNotNan", [instance]);
- if (schema.minimum && instance < schema.minimum)
+ if ('minimum' in schema && instance < schema.minimum)
this.addError(path, "numberMinValue", [schema.minimum]);
- if (schema.maximum && instance > schema.maximum)
+ if ('maximum' in schema && instance > schema.maximum)
this.addError(path, "numberMaxValue", [schema.maximum]);
if (schema.maxDecimal && instance * Math.pow(10, schema.maxDecimal) % 1)
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/tabs/basics/move.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698