diff --git a/src/ecmascript/quickjs/console.cpp b/src/ecmascript/quickjs/console.cpp index a7b760c57..0eda22e1d 100644 --- a/src/ecmascript/quickjs/console.cpp +++ b/src/ecmascript/quickjs/console.cpp @@ -166,7 +166,7 @@ js_console_init(JSContext *ctx) JS_SetConstructor(ctx, console_class, console_proto); JS_SetClassProto(ctx, js_console_class_id, console_proto); - JS_SetPropertyStr(ctx, global_obj, "console", console_proto); + JS_SetPropertyStr(ctx, global_obj, "console", JS_DupValue(ctx, console_proto)); JS_FreeValue(ctx, global_obj); diff --git a/src/ecmascript/quickjs/document.cpp b/src/ecmascript/quickjs/document.cpp index b1d33e6a4..ab1523926 100644 --- a/src/ecmascript/quickjs/document.cpp +++ b/src/ecmascript/quickjs/document.cpp @@ -1752,7 +1752,7 @@ js_document_init(JSContext *ctx) JS_SetConstructor(ctx, document_class, document_proto); JS_SetClassProto(ctx, js_document_class_id, document_proto); - JS_SetPropertyStr(ctx, global_obj, "document", document_proto); + JS_SetPropertyStr(ctx, global_obj, "document", JS_DupValue(ctx, document_proto)); JS_FreeValue(ctx, global_obj); diff --git a/src/ecmascript/quickjs/history.cpp b/src/ecmascript/quickjs/history.cpp index 59dfdf895..070c43737 100644 --- a/src/ecmascript/quickjs/history.cpp +++ b/src/ecmascript/quickjs/history.cpp @@ -201,7 +201,7 @@ js_history_init(JSContext *ctx) JS_SetConstructor(ctx, history_class, history_proto); JS_SetClassProto(ctx, js_history_class_id, history_proto); - JS_SetPropertyStr(ctx, global_obj, "history", history_proto); + JS_SetPropertyStr(ctx, global_obj, "history", JS_DupValue(ctx, history_proto)); JS_FreeValue(ctx, global_obj); diff --git a/src/ecmascript/quickjs/localstorage.cpp b/src/ecmascript/quickjs/localstorage.cpp index fc2be3184..963eaa31f 100644 --- a/src/ecmascript/quickjs/localstorage.cpp +++ b/src/ecmascript/quickjs/localstorage.cpp @@ -252,9 +252,13 @@ js_localstorage_init(JSContext *ctx) REF_JS(localstorage_obj); JS_SetPropertyFunctionList(ctx, localstorage_obj, js_localstorage_proto_funcs, countof(js_localstorage_proto_funcs)); - JS_SetClassProto(ctx, js_localstorage_class_id, localstorage_obj); + REF_JS(localstorage_obj); - JS_SetPropertyStr(ctx, global_obj, "localStorage", localstorage_obj); + JS_SetClassProto(ctx, js_localstorage_class_id, localstorage_obj); + REF_JS(localstorage_obj); + + JS_SetPropertyStr(ctx, global_obj, "localStorage", JS_DupValue(ctx, localstorage_obj)); + REF_JS(localstorage_obj); JS_FreeValue(ctx, global_obj); diff --git a/src/ecmascript/quickjs/location.cpp b/src/ecmascript/quickjs/location.cpp index decaf1aac..461a9e392 100644 --- a/src/ecmascript/quickjs/location.cpp +++ b/src/ecmascript/quickjs/location.cpp @@ -703,7 +703,7 @@ js_location_init(JSContext *ctx) JS_SetConstructor(ctx, location_class, location_proto); JS_SetClassProto(ctx, js_location_class_id, location_proto); - JS_SetPropertyStr(ctx, global_obj, "location", location_proto); + JS_SetPropertyStr(ctx, global_obj, "location", JS_DupValue(ctx, location_proto)); JS_FreeValue(ctx, global_obj); diff --git a/src/ecmascript/quickjs/navigator.cpp b/src/ecmascript/quickjs/navigator.cpp index 03f0c1ad6..2d22d112d 100644 --- a/src/ecmascript/quickjs/navigator.cpp +++ b/src/ecmascript/quickjs/navigator.cpp @@ -228,7 +228,7 @@ js_navigator_init(JSContext *ctx) JS_SetConstructor(ctx, navigator_class, navigator_proto); JS_SetClassProto(ctx, js_navigator_class_id, navigator_proto); - JS_SetPropertyStr(ctx, global_obj, "navigator", navigator_proto); + JS_SetPropertyStr(ctx, global_obj, "navigator", JS_DupValue(ctx, navigator_proto)); JS_FreeValue(ctx, global_obj); diff --git a/src/ecmascript/quickjs/screen.cpp b/src/ecmascript/quickjs/screen.cpp index 9107f6b01..1a4a667aa 100644 --- a/src/ecmascript/quickjs/screen.cpp +++ b/src/ecmascript/quickjs/screen.cpp @@ -217,7 +217,7 @@ js_screen_init(JSContext *ctx) JS_SetConstructor(ctx, screen_class, screen_proto); JS_SetClassProto(ctx, js_screen_class_id, screen_proto); - JS_SetPropertyStr(ctx, global_obj, "screen", screen_proto); + JS_SetPropertyStr(ctx, global_obj, "screen", JS_DupValue(ctx, screen_proto)); JS_FreeValue(ctx, global_obj); diff --git a/src/ecmascript/quickjs/unibar.cpp b/src/ecmascript/quickjs/unibar.cpp index 41564fd3e..f8bef2ed3 100644 --- a/src/ecmascript/quickjs/unibar.cpp +++ b/src/ecmascript/quickjs/unibar.cpp @@ -234,7 +234,7 @@ js_unibar_init(JSContext *ctx) /* set proto.constructor and ctor.prototype */ JS_SetConstructor(ctx, menubar_class, menubar_proto); JS_SetClassProto(ctx, js_menubar_class_id, menubar_proto); - JS_SetPropertyStr(ctx, global_obj, "menubar", menubar_proto); + JS_SetPropertyStr(ctx, global_obj, "menubar", JS_DupValue(ctx, menubar_proto)); /* create the statusbar class */ JS_NewClassID(&js_statusbar_class_id); @@ -250,7 +250,7 @@ js_unibar_init(JSContext *ctx) /* set proto.constructor and ctor.prototype */ JS_SetConstructor(ctx, statusbar_class, statusbar_proto); JS_SetClassProto(ctx, js_statusbar_class_id, statusbar_proto); - JS_SetPropertyStr(ctx, global_obj, "statusbar", statusbar_proto); + JS_SetPropertyStr(ctx, global_obj, "statusbar", JS_DupValue(ctx, statusbar_proto)); JS_FreeValue(ctx, global_obj);