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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/ScriptStreamer.cpp

Issue 2245003002: [Binding] Load 4 bytes to detect BOM (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698