Skip to content

Commit e93b40c

Browse files
committed
有些对象是不可以设置属性的,比如JS_CLASS_MODULE_NS
1 parent 605cf55 commit e93b40c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

include/CppObjectMapperQuickjs.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ struct CppObjectMapper
9393

9494
inline bool GetPrivate(JSValue val, void** outPrr) const
9595
{
96-
if (!JS_IsObject(val))
96+
if (!JS_IsObject(val) || !JS_IsExtensible(ctx, val))
9797
{
98+
*outPrr = nullptr;
9899
return false;
99100
}
100101

@@ -113,7 +114,7 @@ struct CppObjectMapper
113114

114115
inline bool SetPrivate(JSValue val, void* ptr)
115116
{
116-
if (!JS_IsObject(val))
117+
if (!JS_IsObject(val) || !JS_IsExtensible(ctx, val))
117118
{
118119
return false;
119120
}

0 commit comments

Comments
 (0)