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

Side by Side Diff: third_party/WebKit/Source/platform/v8_inspector/V8DebuggerScript.cpp

Issue 2232083002: Fix incorrect usage of StringImpl::sizeInBytes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: size_teeee 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/v8_inspector/V8DebuggerScript.h" 5 #include "platform/v8_inspector/V8DebuggerScript.h"
6 6
7 #include "platform/inspector_protocol/Collections.h" 7 #include "platform/inspector_protocol/Collections.h"
8 #include "platform/inspector_protocol/Platform.h" 8 #include "platform/inspector_protocol/Platform.h"
9 #include "platform/v8_inspector/V8StringUtil.h" 9 #include "platform/v8_inspector/V8StringUtil.h"
10 10
(...skipping 19 matching lines...) Expand all
30 static uint32_t randomOdd[] = { 0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA1 1D, 0x8F462907 }; 30 static uint32_t randomOdd[] = { 0xB4663807, 0xCC322BF5, 0xD4F91BBD, 0xA7BEA1 1D, 0x8F462907 };
31 31
32 uint64_t hashes[] = { 0, 0, 0, 0, 0 }; 32 uint64_t hashes[] = { 0, 0, 0, 0, 0 };
33 uint64_t zi[] = { 1, 1, 1, 1, 1 }; 33 uint64_t zi[] = { 1, 1, 1, 1, 1 };
34 34
35 const size_t hashesSize = PROTOCOL_ARRAY_LENGTH(hashes); 35 const size_t hashesSize = PROTOCOL_ARRAY_LENGTH(hashes);
36 36
37 size_t current = 0; 37 size_t current = 0;
38 const uint32_t* data = nullptr; 38 const uint32_t* data = nullptr;
39 data = reinterpret_cast<const uint32_t*>(str.characters16()); 39 data = reinterpret_cast<const uint32_t*>(str.characters16());
40 for (size_t i = 0; i < str.sizeInBytes() / 4; i += 4) { 40 size_t charactersSizeInBytes = str.charactersSizeInBytes();
41 for (size_t i = 0; i < charactersSizeInBytes / 4; i += 4) {
41 uint32_t v = data[i]; 42 uint32_t v = data[i];
42 uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; 43 uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF;
43 hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; 44 hashes[current] = (hashes[current] + zi[current] * xi) % prime[current];
44 zi[current] = (zi[current] * random[current]) % prime[current]; 45 zi[current] = (zi[current] * random[current]) % prime[current];
45 current = current == hashesSize - 1 ? 0 : current + 1; 46 current = current == hashesSize - 1 ? 0 : current + 1;
46 } 47 }
47 if (str.sizeInBytes() % 4) { 48 if (charactersSizeInBytes % 4) {
48 uint32_t v = 0; 49 uint32_t v = 0;
49 for (size_t i = str.sizeInBytes() - str.sizeInBytes() % 4; i < str.sizeI nBytes(); ++i) { 50 for (size_t i = charactersSizeInBytes - charactersSizeInBytes % 4; i < c haractersSizeInBytes; ++i) {
50 v <<= 8; 51 v <<= 8;
51 v |= reinterpret_cast<const uint8_t*>(data)[i]; 52 v |= reinterpret_cast<const uint8_t*>(data)[i];
52 } 53 }
53 uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF; 54 uint64_t xi = v * randomOdd[current] & 0x7FFFFFFF;
54 hashes[current] = (hashes[current] + zi[current] * xi) % prime[current]; 55 hashes[current] = (hashes[current] + zi[current] * xi) % prime[current];
55 zi[current] = (zi[current] * random[current]) % prime[current]; 56 zi[current] = (zi[current] * random[current]) % prime[current];
56 current = current == hashesSize - 1 ? 0 : current + 1; 57 current = current == hashesSize - 1 ? 0 : current + 1;
57 } 58 }
58 59
59 for (size_t i = 0; i < hashesSize; ++i) 60 for (size_t i = 0; i < hashesSize; ++i)
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 m_sourceMappingURL = sourceMappingURL; 113 m_sourceMappingURL = sourceMappingURL;
113 } 114 }
114 115
115 void V8DebuggerScript::setSource(v8::Isolate* isolate, v8::Local<v8::String> sou rce) 116 void V8DebuggerScript::setSource(v8::Isolate* isolate, v8::Local<v8::String> sou rce)
116 { 117 {
117 m_source.Reset(isolate, source); 118 m_source.Reset(isolate, source);
118 m_hash = calculateHash(toProtocolString(source)); 119 m_hash = calculateHash(toProtocolString(source));
119 } 120 }
120 121
121 } // namespace blink 122 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/inspector_protocol/String16WTF.h ('k') | third_party/WebKit/Source/wtf/text/AtomicString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698