Commit dc9f0d46 authored by yangguo's avatar yangguo Committed by Commit bot

Throw illegal exception when formatting with invalid template index.

R=arv@chromium.org
BUG=chromium:492526
LOG=N

Review URL: https://codereview.chromium.org/1146923004

Cr-Commit-Position: refs/heads/master@{#28671}
parent 36d8363c
......@@ -331,6 +331,7 @@ MaybeHandle<String> MessageTemplate::FormatMessage(int template_index,
Handle<String> arg0,
Handle<String> arg1,
Handle<String> arg2) {
Isolate* isolate = arg0->GetIsolate();
const char* template_string;
switch (template_index) {
#define CASE(NAME, STRING) \
......@@ -341,12 +342,10 @@ MaybeHandle<String> MessageTemplate::FormatMessage(int template_index,
#undef CASE
case kLastMessage:
default:
UNREACHABLE();
template_string = "";
break;
isolate->ThrowIllegalOperation();
return MaybeHandle<String>();
}
Isolate* isolate = arg0->GetIsolate();
IncrementalStringBuilder builder(isolate);
unsigned int i = 0;
......
// Copyright 2015 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.
// Flags: --allow-natives-syntax
assertThrows(function() { %FormatMessageString(-1, "", "", ""); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment