iotjs icon indicating copy to clipboard operation
iotjs copied to clipboard

Make sure JObjectWrap never could be created as local variable.

Open ILyoan opened this issue 11 years ago • 3 comments

Instance of JObjectWrap never be created as local variable.

Constructor of JObjectWrap set native pointer for javascript object so that when the object was reclaimed by garbage collector, the wrapper will also be reclaimed. If wrapper was created as local variable, this may lead double free.

And first of all, JObjectWrap was designed to be used for holding javascript object throughout asynchronous program execution, not just for local time span. JObject would just be fine for handling local javascript object.

Preventing creating instance of JObjectWrap by moving constructor into private section and exposing static method for creating wrapper at heap space is an option.

ILyoan avatar Jul 24 '15 08:07 ILyoan

No objection? Then I'll do this after HTTP and GPIO landed.

ILyoan avatar Aug 03 '15 05:08 ILyoan

No objection. I am in.

chunseoklee avatar Aug 03 '15 07:08 chunseoklee

I could not found the effective way to prevent it. Guide not to create an instance of JObjectWrap as local variable. (https://github.com/Samsung/iotjs/wiki/Inside%20IoT.js#jobjectwrap)

Close as won't fix.

ILyoan avatar Nov 09 '15 09:11 ILyoan