Changeset 150381 in webkit
- Timestamp:
- May 20, 2013 2:10:19 PM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/API/JSBase.cpp
r148696 r150381 45 45 JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) 46 46 { 47 if (!ctx) { 48 ASSERT_NOT_REACHED(); 49 return 0; 50 } 47 51 ExecState* exec = toJS(ctx); 48 52 APIEntryShim entryShim(exec); … … 72 76 bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) 73 77 { 78 if (!ctx) { 79 ASSERT_NOT_REACHED(); 80 return false; 81 } 74 82 ExecState* exec = toJS(ctx); 75 83 APIEntryShim entryShim(exec); … … 107 115 void JSReportExtraMemoryCost(JSContextRef ctx, size_t size) 108 116 { 117 if (!ctx) { 118 ASSERT_NOT_REACHED(); 119 return; 120 } 109 121 ExecState* exec = toJS(ctx); 110 122 APIEntryShim entryShim(exec); -
trunk/Source/JavaScriptCore/API/JSContextRef.cpp
r149420 r150381 180 180 JSObjectRef JSContextGetGlobalObject(JSContextRef ctx) 181 181 { 182 if (!ctx) { 183 ASSERT_NOT_REACHED(); 184 return 0; 185 } 182 186 ExecState* exec = toJS(ctx); 183 187 APIEntryShim entryShim(exec); … … 189 193 JSContextGroupRef JSContextGetGroup(JSContextRef ctx) 190 194 { 195 if (!ctx) { 196 ASSERT_NOT_REACHED(); 197 return 0; 198 } 191 199 ExecState* exec = toJS(ctx); 192 200 return toRef(&exec->vm()); … … 195 203 JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx) 196 204 { 205 if (!ctx) { 206 ASSERT_NOT_REACHED(); 207 return 0; 208 } 197 209 ExecState* exec = toJS(ctx); 198 210 APIEntryShim entryShim(exec); … … 203 215 JSStringRef JSContextCreateBacktrace(JSContextRef ctx, unsigned maxStackSize) 204 216 { 217 if (!ctx) { 218 ASSERT_NOT_REACHED(); 219 return 0; 220 } 205 221 ExecState* exec = toJS(ctx); 206 222 JSLockHolder lock(exec); -
trunk/Source/JavaScriptCore/API/JSObjectRef.cpp
r148696 r150381 81 81 JSObjectRef JSObjectMake(JSContextRef ctx, JSClassRef jsClass, void* data) 82 82 { 83 if (!ctx) { 84 ASSERT_NOT_REACHED(); 85 return 0; 86 } 83 87 ExecState* exec = toJS(ctx); 84 88 APIEntryShim entryShim(exec); … … 96 100 JSObjectRef JSObjectMakeFunctionWithCallback(JSContextRef ctx, JSStringRef name, JSObjectCallAsFunctionCallback callAsFunction) 97 101 { 102 if (!ctx) { 103 ASSERT_NOT_REACHED(); 104 return 0; 105 } 98 106 ExecState* exec = toJS(ctx); 99 107 APIEntryShim entryShim(exec); … … 103 111 JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor) 104 112 { 113 if (!ctx) { 114 ASSERT_NOT_REACHED(); 115 return 0; 116 } 105 117 ExecState* exec = toJS(ctx); 106 118 APIEntryShim entryShim(exec); … … 117 129 JSObjectRef JSObjectMakeFunction(JSContextRef ctx, JSStringRef name, unsigned parameterCount, const JSStringRef parameterNames[], JSStringRef body, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) 118 130 { 131 if (!ctx) { 132 ASSERT_NOT_REACHED(); 133 return 0; 134 } 119 135 ExecState* exec = toJS(ctx); 120 136 APIEntryShim entryShim(exec); … … 139 155 JSObjectRef JSObjectMakeArray(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 140 156 { 157 if (!ctx) { 158 ASSERT_NOT_REACHED(); 159 return 0; 160 } 141 161 ExecState* exec = toJS(ctx); 142 162 APIEntryShim entryShim(exec); … … 164 184 JSObjectRef JSObjectMakeDate(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 165 185 { 186 if (!ctx) { 187 ASSERT_NOT_REACHED(); 188 return 0; 189 } 166 190 ExecState* exec = toJS(ctx); 167 191 APIEntryShim entryShim(exec); … … 184 208 JSObjectRef JSObjectMakeError(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 185 209 { 210 if (!ctx) { 211 ASSERT_NOT_REACHED(); 212 return 0; 213 } 186 214 ExecState* exec = toJS(ctx); 187 215 APIEntryShim entryShim(exec); … … 203 231 JSObjectRef JSObjectMakeRegExp(JSContextRef ctx, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) 204 232 { 233 if (!ctx) { 234 ASSERT_NOT_REACHED(); 235 return 0; 236 } 205 237 ExecState* exec = toJS(ctx); 206 238 APIEntryShim entryShim(exec); … … 223 255 JSValueRef JSObjectGetPrototype(JSContextRef ctx, JSObjectRef object) 224 256 { 257 if (!ctx) { 258 ASSERT_NOT_REACHED(); 259 return 0; 260 } 225 261 ExecState* exec = toJS(ctx); 226 262 APIEntryShim entryShim(exec); … … 232 268 void JSObjectSetPrototype(JSContextRef ctx, JSObjectRef object, JSValueRef value) 233 269 { 270 if (!ctx) { 271 ASSERT_NOT_REACHED(); 272 return; 273 } 234 274 ExecState* exec = toJS(ctx); 235 275 APIEntryShim entryShim(exec); … … 243 283 bool JSObjectHasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName) 244 284 { 285 if (!ctx) { 286 ASSERT_NOT_REACHED(); 287 return false; 288 } 245 289 ExecState* exec = toJS(ctx); 246 290 APIEntryShim entryShim(exec); … … 253 297 JSValueRef JSObjectGetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) 254 298 { 299 if (!ctx) { 300 ASSERT_NOT_REACHED(); 301 return 0; 302 } 255 303 ExecState* exec = toJS(ctx); 256 304 APIEntryShim entryShim(exec); … … 269 317 void JSObjectSetProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes, JSValueRef* exception) 270 318 { 319 if (!ctx) { 320 ASSERT_NOT_REACHED(); 321 return; 322 } 271 323 ExecState* exec = toJS(ctx); 272 324 APIEntryShim entryShim(exec); … … 292 344 JSValueRef JSObjectGetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception) 293 345 { 346 if (!ctx) { 347 ASSERT_NOT_REACHED(); 348 return 0; 349 } 294 350 ExecState* exec = toJS(ctx); 295 351 APIEntryShim entryShim(exec); … … 309 365 void JSObjectSetPropertyAtIndex(JSContextRef ctx, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception) 310 366 { 367 if (!ctx) { 368 ASSERT_NOT_REACHED(); 369 return; 370 } 311 371 ExecState* exec = toJS(ctx); 312 372 APIEntryShim entryShim(exec); … … 325 385 bool JSObjectDeleteProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) 326 386 { 387 if (!ctx) { 388 ASSERT_NOT_REACHED(); 389 return false; 390 } 327 391 ExecState* exec = toJS(ctx); 328 392 APIEntryShim entryShim(exec); … … 539 603 JSPropertyNameArrayRef JSObjectCopyPropertyNames(JSContextRef ctx, JSObjectRef object) 540 604 { 605 if (!ctx) { 606 ASSERT_NOT_REACHED(); 607 return 0; 608 } 541 609 JSObject* jsObject = toJS(object); 542 610 ExecState* exec = toJS(ctx); -
trunk/Source/JavaScriptCore/API/JSValueRef.cpp
r146494 r150381 65 65 ::JSType JSValueGetType(JSContextRef ctx, JSValueRef value) 66 66 { 67 if (!ctx) { 68 ASSERT_NOT_REACHED(); 69 return kJSTypeUndefined; 70 } 67 71 ExecState* exec = toJS(ctx); 68 72 APIEntryShim entryShim(exec); … … 86 90 bool JSValueIsUndefined(JSContextRef ctx, JSValueRef value) 87 91 { 92 if (!ctx) { 93 ASSERT_NOT_REACHED(); 94 return false; 95 } 88 96 ExecState* exec = toJS(ctx); 89 97 APIEntryShim entryShim(exec); … … 95 103 bool JSValueIsNull(JSContextRef ctx, JSValueRef value) 96 104 { 105 if (!ctx) { 106 ASSERT_NOT_REACHED(); 107 return false; 108 } 97 109 ExecState* exec = toJS(ctx); 98 110 APIEntryShim entryShim(exec); … … 104 116 bool JSValueIsBoolean(JSContextRef ctx, JSValueRef value) 105 117 { 118 if (!ctx) { 119 ASSERT_NOT_REACHED(); 120 return false; 121 } 106 122 ExecState* exec = toJS(ctx); 107 123 APIEntryShim entryShim(exec); … … 113 129 bool JSValueIsNumber(JSContextRef ctx, JSValueRef value) 114 130 { 131 if (!ctx) { 132 ASSERT_NOT_REACHED(); 133 return false; 134 } 115 135 ExecState* exec = toJS(ctx); 116 136 APIEntryShim entryShim(exec); … … 122 142 bool JSValueIsString(JSContextRef ctx, JSValueRef value) 123 143 { 144 if (!ctx) { 145 ASSERT_NOT_REACHED(); 146 return false; 147 } 124 148 ExecState* exec = toJS(ctx); 125 149 APIEntryShim entryShim(exec); … … 131 155 bool JSValueIsObject(JSContextRef ctx, JSValueRef value) 132 156 { 157 if (!ctx) { 158 ASSERT_NOT_REACHED(); 159 return false; 160 } 133 161 ExecState* exec = toJS(ctx); 134 162 APIEntryShim entryShim(exec); … … 140 168 bool JSValueIsObjectOfClass(JSContextRef ctx, JSValueRef value, JSClassRef jsClass) 141 169 { 170 if (!ctx || !jsClass) { 171 ASSERT_NOT_REACHED(); 172 return false; 173 } 142 174 ExecState* exec = toJS(ctx); 143 175 APIEntryShim entryShim(exec); … … 160 192 bool JSValueIsEqual(JSContextRef ctx, JSValueRef a, JSValueRef b, JSValueRef* exception) 161 193 { 194 if (!ctx) { 195 ASSERT_NOT_REACHED(); 196 return false; 197 } 162 198 ExecState* exec = toJS(ctx); 163 199 APIEntryShim entryShim(exec); … … 177 213 bool JSValueIsStrictEqual(JSContextRef ctx, JSValueRef a, JSValueRef b) 178 214 { 215 if (!ctx) { 216 ASSERT_NOT_REACHED(); 217 return false; 218 } 179 219 ExecState* exec = toJS(ctx); 180 220 APIEntryShim entryShim(exec); … … 188 228 bool JSValueIsInstanceOfConstructor(JSContextRef ctx, JSValueRef value, JSObjectRef constructor, JSValueRef* exception) 189 229 { 230 if (!ctx) { 231 ASSERT_NOT_REACHED(); 232 return false; 233 } 190 234 ExecState* exec = toJS(ctx); 191 235 APIEntryShim entryShim(exec); … … 207 251 JSValueRef JSValueMakeUndefined(JSContextRef ctx) 208 252 { 253 if (!ctx) { 254 ASSERT_NOT_REACHED(); 255 return 0; 256 } 209 257 ExecState* exec = toJS(ctx); 210 258 APIEntryShim entryShim(exec); … … 215 263 JSValueRef JSValueMakeNull(JSContextRef ctx) 216 264 { 265 if (!ctx) { 266 ASSERT_NOT_REACHED(); 267 return 0; 268 } 217 269 ExecState* exec = toJS(ctx); 218 270 APIEntryShim entryShim(exec); … … 223 275 JSValueRef JSValueMakeBoolean(JSContextRef ctx, bool value) 224 276 { 277 if (!ctx) { 278 ASSERT_NOT_REACHED(); 279 return 0; 280 } 225 281 ExecState* exec = toJS(ctx); 226 282 APIEntryShim entryShim(exec); … … 231 287 JSValueRef JSValueMakeNumber(JSContextRef ctx, double value) 232 288 { 289 if (!ctx) { 290 ASSERT_NOT_REACHED(); 291 return 0; 292 } 233 293 ExecState* exec = toJS(ctx); 234 294 APIEntryShim entryShim(exec); … … 245 305 JSValueRef JSValueMakeString(JSContextRef ctx, JSStringRef string) 246 306 { 307 if (!ctx) { 308 ASSERT_NOT_REACHED(); 309 return 0; 310 } 247 311 ExecState* exec = toJS(ctx); 248 312 APIEntryShim entryShim(exec); … … 253 317 JSValueRef JSValueMakeFromJSONString(JSContextRef ctx, JSStringRef string) 254 318 { 319 if (!ctx) { 320 ASSERT_NOT_REACHED(); 321 return 0; 322 } 255 323 ExecState* exec = toJS(ctx); 256 324 APIEntryShim entryShim(exec); … … 267 335 JSStringRef JSValueCreateJSONString(JSContextRef ctx, JSValueRef apiValue, unsigned indent, JSValueRef* exception) 268 336 { 337 if (!ctx) { 338 ASSERT_NOT_REACHED(); 339 return 0; 340 } 269 341 ExecState* exec = toJS(ctx); 270 342 APIEntryShim entryShim(exec); … … 284 356 bool JSValueToBoolean(JSContextRef ctx, JSValueRef value) 285 357 { 358 if (!ctx) { 359 ASSERT_NOT_REACHED(); 360 return false; 361 } 286 362 ExecState* exec = toJS(ctx); 287 363 APIEntryShim entryShim(exec); … … 293 369 double JSValueToNumber(JSContextRef ctx, JSValueRef value, JSValueRef* exception) 294 370 { 371 if (!ctx) { 372 ASSERT_NOT_REACHED(); 373 return QNaN; 374 } 295 375 ExecState* exec = toJS(ctx); 296 376 APIEntryShim entryShim(exec); … … 310 390 JSStringRef JSValueToStringCopy(JSContextRef ctx, JSValueRef value, JSValueRef* exception) 311 391 { 392 if (!ctx) { 393 ASSERT_NOT_REACHED(); 394 return 0; 395 } 312 396 ExecState* exec = toJS(ctx); 313 397 APIEntryShim entryShim(exec); … … 327 411 JSObjectRef JSValueToObject(JSContextRef ctx, JSValueRef value, JSValueRef* exception) 328 412 { 413 if (!ctx) { 414 ASSERT_NOT_REACHED(); 415 return 0; 416 } 329 417 ExecState* exec = toJS(ctx); 330 418 APIEntryShim entryShim(exec); … … 344 432 void JSValueProtect(JSContextRef ctx, JSValueRef value) 345 433 { 434 if (!ctx) { 435 ASSERT_NOT_REACHED(); 436 return; 437 } 346 438 ExecState* exec = toJS(ctx); 347 439 APIEntryShim entryShim(exec); -
trunk/Source/JavaScriptCore/API/JSWeakObjectMapRefPrivate.cpp
r147962 r150381 55 55 void JSWeakObjectMapSet(JSContextRef ctx, JSWeakObjectMapRef map, void* key, JSObjectRef object) 56 56 { 57 if (!ctx) { 58 ASSERT_NOT_REACHED(); 59 return; 60 } 57 61 ExecState* exec = toJS(ctx); 58 62 APIEntryShim entryShim(exec); … … 66 70 JSObjectRef JSWeakObjectMapGet(JSContextRef ctx, JSWeakObjectMapRef map, void* key) 67 71 { 72 if (!ctx) { 73 ASSERT_NOT_REACHED(); 74 return 0; 75 } 68 76 ExecState* exec = toJS(ctx); 69 77 APIEntryShim entryShim(exec); … … 73 81 void JSWeakObjectMapRemove(JSContextRef ctx, JSWeakObjectMapRef map, void* key) 74 82 { 83 if (!ctx) { 84 ASSERT_NOT_REACHED(); 85 return; 86 } 75 87 ExecState* exec = toJS(ctx); 76 88 APIEntryShim entryShim(exec); -
trunk/Source/JavaScriptCore/ChangeLog
r150367 r150381 1 2013-05-20 Oliver Hunt <oliver@apple.com> 2 3 Make C API more robust against null contexts 4 https://bugs.webkit.org/show_bug.cgi?id=116462 5 6 Reviewed by Anders Carlsson. 7 8 Handle null contexts in a non-crashy way. It's a bug to ever call the 9 API with a null context, and the absence of a context means we can't 10 produce a meaningful result, so we still assert in debug builds. 11 12 Now where possible we detect and early return, returning null for any 13 pointer type, NaN for doubles, and false for any boolean result. 14 15 * API/JSBase.cpp: 16 (JSEvaluateScript): 17 (JSCheckScriptSyntax): 18 (JSReportExtraMemoryCost): 19 * API/JSContextRef.cpp: 20 (JSContextGetGlobalObject): 21 (JSContextGetGroup): 22 (JSContextGetGlobalContext): 23 (JSContextCreateBacktrace): 24 * API/JSObjectRef.cpp: 25 (JSObjectMake): 26 (JSObjectMakeFunctionWithCallback): 27 (JSObjectMakeConstructor): 28 (JSObjectMakeFunction): 29 (JSObjectMakeArray): 30 (JSObjectMakeDate): 31 (JSObjectMakeError): 32 (JSObjectMakeRegExp): 33 (JSObjectGetPrototype): 34 (JSObjectSetPrototype): 35 (JSObjectHasProperty): 36 (JSObjectGetProperty): 37 (JSObjectSetProperty): 38 (JSObjectGetPropertyAtIndex): 39 (JSObjectSetPropertyAtIndex): 40 (JSObjectDeleteProperty): 41 (JSObjectCopyPropertyNames): 42 * API/JSValueRef.cpp: 43 (JSValueGetType): 44 (JSValueIsUndefined): 45 (JSValueIsNull): 46 (JSValueIsBoolean): 47 (JSValueIsNumber): 48 (JSValueIsString): 49 (JSValueIsObject): 50 (JSValueIsObjectOfClass): 51 (JSValueIsEqual): 52 (JSValueIsStrictEqual): 53 (JSValueIsInstanceOfConstructor): 54 (JSValueMakeUndefined): 55 (JSValueMakeNull): 56 (JSValueMakeBoolean): 57 (JSValueMakeNumber): 58 (JSValueMakeString): 59 (JSValueMakeFromJSONString): 60 (JSValueCreateJSONString): 61 (JSValueToBoolean): 62 (JSValueToNumber): 63 (JSValueToStringCopy): 64 (JSValueToObject): 65 (JSValueProtect): 66 * API/JSWeakObjectMapRefPrivate.cpp: 67 1 68 2013-05-20 David Kilzer <ddkilzer@apple.com> 2 69
Note: See TracChangeset
for help on using the changeset viewer.