Changeset 76185 in webkit for trunk/Source/JavaScriptCore
- Timestamp:
- Jan 19, 2011, 5:53:50 PM (14 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/Android.mk
r75855 r76185 152 152 runtime/StringObject.cpp \ 153 153 runtime/StringPrototype.cpp \ 154 runtime/StringRecursionChecker.cpp \ 154 155 runtime/Structure.cpp \ 155 156 runtime/StructureChain.cpp \ -
trunk/Source/JavaScriptCore/CMakeLists.txt
r75855 r76185 164 164 runtime/StringObject.cpp 165 165 runtime/StringPrototype.cpp 166 runtime/StringRecursionChecker.cpp 166 167 runtime/Structure.cpp 167 168 runtime/StructureChain.cpp -
trunk/Source/JavaScriptCore/ChangeLog
r76180 r76185 1 2011-01-18 Darin Adler <[email protected]> 2 3 Reviewed by Geoffrey Garen. 4 5 Stack overflow when converting an Error object to string 6 https://bugs.webkit.org/show_bug.cgi?id=46410 7 8 * Android.mk: Added StringRecursionChecker.cpp and 9 StringRecursionChecker.h. 10 * CMakeLists.txt: Ditto. 11 * GNUmakefile.am: Ditto. 12 * JavaScriptCore.gypi: Ditto. 13 * JavaScriptCore.pro: Ditto. 14 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Ditto. 15 * JavaScriptCore.xcodeproj/project.pbxproj: Ditto. 16 17 * runtime/ArrayPrototype.cpp: 18 (JSC::arrayProtoFuncToString): Use StringRecursionChecker instead 19 of the older hand-written code to do the same thing. 20 (JSC::arrayProtoFuncToLocaleString): Ditto. 21 (JSC::arrayProtoFuncJoin): Ditto. 22 23 * runtime/ErrorPrototype.cpp: 24 (JSC::errorProtoFuncToString): Use StringRecursionChecker. 25 26 * runtime/JSGlobalData.h: Renamed arrayVisitedElements to 27 stringRecursionCheckVisitedObjects. 28 29 * runtime/RegExpPrototype.cpp: 30 (JSC::regExpProtoFuncToString): Use StringRecursionChecker. 31 32 * runtime/StringRecursionChecker.cpp: Added. 33 * runtime/StringRecursionChecker.h: Added. 34 1 35 2011-01-19 Oliver Hunt <[email protected]> 2 36 -
trunk/Source/JavaScriptCore/GNUmakefile.am
r75855 r76185 405 405 Source/JavaScriptCore/runtime/StringPrototype.cpp \ 406 406 Source/JavaScriptCore/runtime/StringPrototype.h \ 407 Source/JavaScriptCore/runtime/StringRecursionChecker.cpp \ 408 Source/JavaScriptCore/runtime/StringRecursionChecker.h \ 407 409 Source/JavaScriptCore/runtime/StructureChain.cpp \ 408 410 Source/JavaScriptCore/runtime/StructureChain.h \ -
trunk/Source/JavaScriptCore/JavaScriptCore.gypi
r75855 r76185 338 338 'runtime/StringPrototype.cpp', 339 339 'runtime/StringPrototype.h', 340 'runtime/StringRecursionChecker.cpp', 341 'runtime/StringRecursionChecker.h', 340 342 'runtime/Structure.cpp', 341 343 'runtime/Structure.h', -
trunk/Source/JavaScriptCore/JavaScriptCore.pro
r75855 r76185 206 206 runtime/StringObject.cpp \ 207 207 runtime/StringPrototype.cpp \ 208 runtime/StringRecursionChecker.cpp \ 208 209 runtime/StructureChain.cpp \ 209 210 runtime/Structure.cpp \ -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
r75855 r76185 1247 1247 </File> 1248 1248 <File 1249 RelativePath="..\..\runtime\StringRecursionChecker.cpp" 1250 > 1251 </File> 1252 <File 1253 RelativePath="..\..\runtime\StringRecursionChecker.h" 1254 > 1255 </File> 1256 <File 1249 1257 RelativePath="..\..\runtime\Structure.cpp" 1250 1258 > -
trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r75855 r76185 295 295 933040040E6A749400786E6A /* SmallStrings.h in Headers */ = {isa = PBXBuildFile; fileRef = 93303FEA0E6A72C000786E6A /* SmallStrings.h */; settings = {ATTRIBUTES = (Private, ); }; }; 296 296 9330402C0E6A764000786E6A /* SmallStrings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93303FE80E6A72B500786E6A /* SmallStrings.cpp */; }; 297 9335F24D12E6765B002B5553 /* StringRecursionChecker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93345A8712D838C400302BE3 /* StringRecursionChecker.cpp */; }; 297 298 933F5CDC1269229B0049191E /* NullPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 933F5CDB126922690049191E /* NullPtr.h */; settings = {ATTRIBUTES = (Private, ); }; }; 298 299 937013480CA97E0E00FA14D3 /* pcre_ucp_searchfuncs.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 937013470CA97E0E00FA14D3 /* pcre_ucp_searchfuncs.cpp */; settings = {COMPILER_FLAGS = "-Wno-sign-compare"; }; }; … … 926 927 93303FE80E6A72B500786E6A /* SmallStrings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmallStrings.cpp; sourceTree = "<group>"; }; 927 928 93303FEA0E6A72C000786E6A /* SmallStrings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmallStrings.h; sourceTree = "<group>"; }; 929 93345A8712D838C400302BE3 /* StringRecursionChecker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringRecursionChecker.cpp; sourceTree = "<group>"; }; 930 93345A8812D838C400302BE3 /* StringRecursionChecker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringRecursionChecker.h; sourceTree = "<group>"; }; 928 931 933A349A038AE7C6008635CE /* Identifier.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = Identifier.h; sourceTree = "<group>"; tabWidth = 8; }; 929 932 933A349D038AE80F008635CE /* Identifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Identifier.cpp; sourceTree = "<group>"; tabWidth = 8; }; … … 1868 1871 BC18C3C50E16EE3300B34460 /* StringPrototype.cpp */, 1869 1872 BC18C3C60E16EE3300B34460 /* StringPrototype.h */, 1873 93345A8712D838C400302BE3 /* StringRecursionChecker.cpp */, 1874 93345A8812D838C400302BE3 /* StringRecursionChecker.h */, 1870 1875 BCDE3AB00E6C82CF001453A7 /* Structure.cpp */, 1871 1876 BCDE3AB10E6C82CF001453A7 /* Structure.h */, … … 2874 2879 86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */, 2875 2880 86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */, 2881 9335F24D12E6765B002B5553 /* StringRecursionChecker.cpp in Sources */, 2876 2882 ); 2877 2883 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/JavaScriptCore/runtime/ArrayPrototype.cpp
r70703 r76185 1 1 /* 2 2 * Copyright (C) 1999-2000 Harri Porten ([email protected]) 3 * Copyright (C) 2003, 2007, 2008, 2009 Apple Inc. All rights reserved.3 * Copyright (C) 2003, 2007, 2008, 2009, 2011 Apple Inc. All rights reserved. 4 4 * Copyright (C) 2003 Peter Kelly ([email protected]) 5 5 * Copyright (C) 2006 Alexey Proskuryakov ([email protected]) … … 33 33 #include "ObjectPrototype.h" 34 34 #include "Operations.h" 35 #include "StringRecursionChecker.h" 35 36 #include <algorithm> 36 37 #include <wtf/Assertions.h> … … 169 170 JSArray* thisObj = asArray(thisValue); 170 171 171 HashSet<JSObject*>& arrayVisitedElements = exec->globalData().arrayVisitedElements; 172 if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) { 173 if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth) 174 return throwVMError(exec, createStackOverflowError(exec)); 175 } 176 177 bool alreadyVisited = !arrayVisitedElements.add(thisObj).second; 178 if (alreadyVisited) 179 return JSValue::encode(jsEmptyString(exec)); // return an empty string, avoiding infinite recursion. 172 StringRecursionChecker checker(exec, thisObj); 173 if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue()) 174 return earlyReturnValue; 180 175 181 176 unsigned length = thisObj->get(exec, exec->propertyNames().length).toUInt32(exec); … … 210 205 break; 211 206 } 212 arrayVisitedElements.remove(thisObj);213 207 if (!totalSize) 214 208 return JSValue::encode(jsEmptyString(exec)); … … 235 229 JSObject* thisObj = asArray(thisValue); 236 230 237 HashSet<JSObject*>& arrayVisitedElements = exec->globalData().arrayVisitedElements; 238 if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) { 239 if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth) 240 return throwVMError(exec, createStackOverflowError(exec)); 241 } 242 243 bool alreadyVisited = !arrayVisitedElements.add(thisObj).second; 244 if (alreadyVisited) 245 return JSValue::encode(jsEmptyString(exec)); // return an empty string, avoding infinite recursion. 231 StringRecursionChecker checker(exec, thisObj); 232 if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue()) 233 return earlyReturnValue; 246 234 247 235 JSStringBuilder strBuffer; … … 265 253 } 266 254 } 267 arrayVisitedElements.remove(thisObj); 255 268 256 return JSValue::encode(strBuffer.build(exec)); 269 257 } … … 273 261 JSObject* thisObj = exec->hostThisValue().toThisObject(exec); 274 262 275 HashSet<JSObject*>& arrayVisitedElements = exec->globalData().arrayVisitedElements; 276 if (arrayVisitedElements.size() >= MaxSmallThreadReentryDepth) { 277 if (arrayVisitedElements.size() >= exec->globalData().maxReentryDepth) 278 return throwVMError(exec, createStackOverflowError(exec)); 279 } 280 281 bool alreadyVisited = !arrayVisitedElements.add(thisObj).second; 282 if (alreadyVisited) 283 return JSValue::encode(jsEmptyString(exec)); // return an empty string, avoding infinite recursion. 263 StringRecursionChecker checker(exec, thisObj); 264 if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue()) 265 return earlyReturnValue; 284 266 285 267 JSStringBuilder strBuffer; … … 336 318 strBuffer.append(element.toString(exec)); 337 319 } 338 arrayVisitedElements.remove(thisObj); 320 339 321 return JSValue::encode(strBuffer.build(exec)); 340 322 } -
trunk/Source/JavaScriptCore/runtime/ErrorPrototype.cpp
r66616 r76185 27 27 #include "ObjectPrototype.h" 28 28 #include "PrototypeFunction.h" 29 #include "StringRecursionChecker.h" 29 30 #include "UString.h" 30 31 … … 48 49 { 49 50 JSObject* thisObj = exec->hostThisValue().toThisObject(exec); 51 52 StringRecursionChecker checker(exec, thisObj); 53 if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue()) 54 return earlyReturnValue; 55 50 56 JSValue name = thisObj->get(exec, exec->propertyNames().name); 51 57 JSValue message = thisObj->get(exec, exec->propertyNames().message); -
trunk/Source/JavaScriptCore/runtime/JSGlobalData.h
r75443 r76185 215 215 JSGlobalObject* dynamicGlobalObject; 216 216 217 HashSet<JSObject*> arrayVisitedElements;217 HashSet<JSObject*> stringRecursionCheckVisitedObjects; 218 218 219 219 Stringifier* firstStringifierToMark; -
trunk/Source/JavaScriptCore/runtime/RegExpPrototype.cpp
r75408 r76185 35 35 #include "RegExp.h" 36 36 #include "RegExpCache.h" 37 #include "StringRecursionChecker.h" 37 38 #include "UStringConcatenate.h" 38 39 … … 112 113 } 113 114 115 RegExpObject* thisObject = asRegExpObject(thisValue); 116 117 StringRecursionChecker checker(exec, thisObject); 118 if (EncodedJSValue earlyReturnValue = checker.earlyReturnValue()) 119 return earlyReturnValue; 120 114 121 char postfix[5] = { '/', 0, 0, 0, 0 }; 115 122 int index = 1; 116 if ( asRegExpObject(thisValue)->get(exec, exec->propertyNames().global).toBoolean(exec))123 if (thisObject->get(exec, exec->propertyNames().global).toBoolean(exec)) 117 124 postfix[index++] = 'g'; 118 if ( asRegExpObject(thisValue)->get(exec, exec->propertyNames().ignoreCase).toBoolean(exec))125 if (thisObject->get(exec, exec->propertyNames().ignoreCase).toBoolean(exec)) 119 126 postfix[index++] = 'i'; 120 if ( asRegExpObject(thisValue)->get(exec, exec->propertyNames().multiline).toBoolean(exec))127 if (thisObject->get(exec, exec->propertyNames().multiline).toBoolean(exec)) 121 128 postfix[index] = 'm'; 122 UString source = asRegExpObject(thisValue)->get(exec, exec->propertyNames().source).toString(exec);129 UString source = thisObject->get(exec, exec->propertyNames().source).toString(exec); 123 130 // If source is empty, use "/(?:)/" to avoid colliding with comment syntax 124 131 return JSValue::encode(jsMakeNontrivialString(exec, "/", source.length() ? source : UString("(?:)"), postfix));
Note:
See TracChangeset
for help on using the changeset viewer.