Changeset 67129 in webkit


Ignore:
Timestamp:
Sep 9, 2010 5:13:29 PM (14 years ago)
Author:
mrowe@apple.com
Message:

<http://webkit.org/b/45502> JSObjectSetPrivateProperty does not handle NULL values as it claims

Reviewed by Oliver Hunt.

  • API/JSObjectRef.cpp:

(JSObjectSetPrivateProperty): Don't call toJS if we have a NULL value as that will cause an assertion
failure. Instead map NULL directly to the null JSValue.

  • API/tests/testapi.c:

(main): Add test coverage for the NULL value case.

Location:
trunk/JavaScriptCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/API/JSObjectRef.cpp

    r60762 r67129  
    383383    APIEntryShim entryShim(exec);
    384384    JSObject* jsObject = toJS(object);
    385     JSValue jsValue = toJS(exec, value);
     385    JSValue jsValue = value ? toJS(exec, value) : JSValue();
    386386    Identifier name(propertyName->identifier(&exec->globalData()));
    387387    if (jsObject->inherits(&JSCallbackObject<JSGlobalObject>::info)) {
  • trunk/JavaScriptCore/API/tests/testapi.c

    r63277 r67129  
    934934    if (!JSObjectSetPrivateProperty(context, myObject, privatePropertyName, aHeapRef)) {
    935935        printf("FAIL: Could not set private property.\n");
    936         failed = 1;       
    937     } else {
     936        failed = 1;
     937    } else
    938938        printf("PASS: Set private property.\n");
    939     }
    940939    aStackRef = 0;
    941940    if (JSObjectSetPrivateProperty(context, aHeapRef, privatePropertyName, aHeapRef)) {
    942941        printf("FAIL: JSObjectSetPrivateProperty should fail on non-API objects.\n");
    943         failed = 1;       
    944     } else {
     942        failed = 1;
     943    } else
    945944        printf("PASS: Did not allow JSObjectSetPrivateProperty on a non-API object.\n");
    946     }
    947945    if (JSObjectGetPrivateProperty(context, myObject, privatePropertyName) != aHeapRef) {
    948946        printf("FAIL: Could not retrieve private property.\n");
     
    955953    } else
    956954        printf("PASS: JSObjectGetPrivateProperty return NULL.\n");
    957    
     955
    958956    if (JSObjectGetProperty(context, myObject, privatePropertyName, 0) == aHeapRef) {
    959957        printf("FAIL: Accessed private property through ordinary property lookup.\n");
     
    961959    } else
    962960        printf("PASS: Cannot access private property through ordinary property lookup.\n");
    963    
     961
    964962    JSGarbageCollect(context);
    965    
     963
    966964    for (int i = 0; i < 10000; i++)
    967965        JSObjectMake(context, 0, 0);
     
    974972        printf("PASS: Private property does not appear to have been collected.\n");
    975973    JSStringRelease(lengthStr);
    976    
     974
     975    if (!JSObjectSetPrivateProperty(context, myObject, privatePropertyName, 0)) {
     976        printf("FAIL: Could not set private property to NULL.\n");
     977        failed = 1;
     978    } else
     979        printf("PASS: Set private property to NULL.\n");
     980    if (JSObjectGetPrivateProperty(context, myObject, privatePropertyName)) {
     981        printf("FAIL: Could not retrieve private property.\n");
     982        failed = 1;
     983    } else
     984        printf("PASS: Retrieved private property.\n");
     985
    977986    JSStringRef validJSON = JSStringCreateWithUTF8CString("{\"aProperty\":true}");
    978987    JSValueRef jsonObject = JSValueMakeFromJSONString(context, validJSON);
  • trunk/JavaScriptCore/ChangeLog

    r67090 r67129  
     12010-09-09  Mark Rowe  <mrowe@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        <http://webkit.org/b/45502> JSObjectSetPrivateProperty does not handle NULL values as it claims
     6
     7        * API/JSObjectRef.cpp:
     8        (JSObjectSetPrivateProperty): Don't call toJS if we have a NULL value as that will cause an assertion
     9        failure. Instead map NULL directly to the null JSValue.
     10        * API/tests/testapi.c:
     11        (main): Add test coverage for the NULL value case.
     12
    1132010-09-09  Csaba Osztrogonác  <ossy@webkit.org>
    214
Note: See TracChangeset for help on using the changeset viewer.