Skip to content

Commit 84a4f38

Browse files
fix(runtime): store nothing natively for a claim whose adapter is released
Assigning a JS object to an index of a native mutable array passed the object's claim to replaceObjectAtIndex:withObject:. Once the claim's adapter was released, the claim loaded as nil and the native write threw NSInvalidArgumentException, which aborted the app. The setter now resolves the value as marshalling does: a claim whose adapter is released is detached, so the object is stored like any plain JS object.
1 parent 95c3c53 commit 84a4f38

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎NativeScript/runtime/ArgConverter.mm‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,7 @@ throw NativeScriptException(isolate, v8::Exception::TypeError(tns::ToV8String(is
15051505
return v8::Intercepted::kNo;
15061506
}
15071507

1508-
BaseDataWrapper* itemWrapper = tns::GetValue(isolate, value);
1508+
BaseDataWrapper* itemWrapper = tns::GetValueForMarshalling(isolate, value);
15091509
if (itemWrapper == nullptr || itemWrapper->Type() != WrapperType::ObjCObject) {
15101510
return v8::Intercepted::kNo;
15111511
}

‎TestRunner/app/tests/GCFinalizerTests.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,10 @@ describe("GC finalizer callbacks", function () {
841841
}
842842
}
843843
expect(handleReleased).toBe(true);
844+
var element = NSObject.new();
845+
var array = NSMutableArray.arrayWithObject(element);
846+
array[0] = object;
847+
expect(array.objectAtIndex(0)).toBe(element);
844848
expect(interop.bufferFromData(bytes)).toBeUndefined();
845849
});
846850
};

0 commit comments

Comments
 (0)