Fix Use-of-uninitialized-value

v8::internal::JSDateTimeFormat::New

Bug: chromium:1177812, chromium:1177623
Change-Id: I91e6babd796c6735e96e3cd1541d8aba51aaefee
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2706353
Commit-Queue: Frank Tang <ftang@chromium.org>
Reviewed-by: Shu-yu Guo <syg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72878}
This commit is contained in:
Frank Tang 2021-02-19 00:40:17 -08:00 committed by Commit Bot
parent e01256e7d9
commit 00038e19ca
3 changed files with 13 additions and 1 deletions

View File

@ -437,7 +437,7 @@ std::string CanonicalizeTimeZoneID(const std::string& input) {
title[1] = 'S';
}
return title;
} else if (memcmp(upper.c_str(), "SYSTEMV/", 8) == 0) {
} else if (strncmp(upper.c_str(), "SYSTEMV/", 8) == 0) {
upper.replace(0, 8, "SystemV/");
return upper;
}

View File

@ -0,0 +1,5 @@
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
assertEquals("UTC", Intl.DateTimeFormat('en', { timeZone: 'Zulu' }).resolvedOptions().timeZone);

View File

@ -0,0 +1,7 @@
// Copyright 2021 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
for (let tz of [ false, [], {}, function () {}]) {
assertThrows(() => new Date().toLocaleString(undefined, { timeZone: tz }), RangeError);
}