Skip to content

Commit

Permalink
Check the type of JSValue is object before calling JSValueIsObjectOfC…
Browse files Browse the repository at this point in the history
…lass
  • Loading branch information
dukescript committed Oct 12, 2019
1 parent 0d25101 commit cdde5d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected List getFieldOrder() {
@param jsClass The JSClass to test against.
@result true if value is an object and has jsClass in its class chain, otherwise false.
*/
int JSValueIsObjectOfClass(Pointer ctx, Pointer value, Pointer jsClass);
boolean JSValueIsObjectOfClass(Pointer ctx, Pointer value, Pointer jsClass);

Pointer JSContextGetGlobalObject(Pointer ctx);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,12 @@ final void jsContext(Pointer ctx) {
}

private boolean isJavaClazz(Pointer obj) {
final int ret = shell.jsc().JSValueIsObjectOfClass(ctx, obj, javaClazz);
return ret == 1;
final JSC jsc = shell.jsc();
int type = jsc.JSValueGetType(ctx, obj);
if (type != 5) {
return false;
}
return jsc.JSValueIsObjectOfClass(ctx, obj, javaClazz);
}


Expand Down

0 comments on commit cdde5d7

Please sign in to comment.