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..1937b3090125dc11c2ee15b81e431f80d8d52f18 100644 |
| --- a/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp |
| +++ b/third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp |
| @@ -498,11 +498,15 @@ 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. |
| - const char* data = 0; |
| - size_t length = resource->resourceBuffer()->getSomeData(data, static_cast<size_t>(0)); |
| + const size_t length = 4; |
| + char maybeBom[length + 1] = {}; |
|
tzik
2016/08/15 06:02:22
nit: s/Bom/BOM/ for consistency?
nit: Do we need "
peria
2016/08/15 07:02:03
Done: BOM, +1
I put "= {}" just in case to clear m
|
| + if (!resource->resourceBuffer()->getAsBytes(maybeBom, 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. |