Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp |
| index 512fa575b9ed32ca913e1b38b3b52ddb8a369fc3..4ee425f082e089c0d59a5cb57f10cc5288085cc4 100644 |
| --- a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp |
| +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp |
| @@ -498,11 +498,14 @@ void ScriptStreamer::notifyAppendData(ScriptResource* resource) |
| // here, because it might contain incomplete UTF-8 characters. Also note |
| // that have at least s_smallScriptThreshold worth of data, which is more |
| // than enough for detecting a BOM. |
|
kouhei (in TOK)
2016/08/15 07:43:49
Let's update this comment too.
kouhei (in TOK)
2016/08/15 08:19:14
Discussed offline, let me retract this.
peria
2016/08/15 08:28:38
Acknowledged.
|
| - const char* data = 0; |
| - size_t length = resource->resourceBuffer()->getSomeData(data, static_cast<size_t>(0)); |
| + char maybeBOM[length] = {}; |
| + if (!resource->resourceBuffer()->getPartAsBytes(maybeBOM, static_cast<size_t>(0), length)) { |
| + NOTREACHED(); |
| + return; |
| + } |
| std::unique_ptr<TextResourceDecoder> decoder(TextResourceDecoder::create("application/javascript", resource->encoding())); |
| - lengthOfBOM = decoder->checkForBOM(data, length); |
| + lengthOfBOM = decoder->checkForBOM(maybeBOM, length); |
| // Maybe the encoding changed because we saw the BOM; get the encoding |
| // from the decoder. |