I am using a DLL with js-ctypes that is made in C.
The method return a string, but when I try access the content of the pointer firefox crashes!
The following code works:
Function declaration:
var getStr = lib.declare("getString",
ctypes.default_abi,
ctypes.char.ptr,
ctypes.int32_t
);
Function call:
let number = new ctypes.int32_t(1);
var str = getStr(number);
console.log(str.toString());
str.readString();
The console.log
output's:
ctypes.char.ptr(ctypes.UInt64("0x64ff5b48"))
But this code don't work:
Function declaration:
var Core = {
init : function(){
this.lib = ctypes.open("library");
this.getStr = this.lib.declare("getString",
ctypes.default_abi,
ctypes.char.ptr,
ctypes.int32_t);
},
close : function(){
this.lib.close();
}
}
Function call
Core.init();
var number = new ctypes.int32_t(1);
var result = Core.getStr(number);
console.log(result.toString());
result.readString();
The console.log
output's:
ctypes.char.ptr(ctypes.UInt64("0x64ff5b48"))
The same thing !
With this way firefox crashes. Anyone know how to solve this? I was doing this way for modulation of the addon.
I found the problem! Thank you Noitidart. In the second example I was closing the library before the
str.readString()
. It makes firefox crash. I tried to reduce the code on the question post and forgot about this detail, I am sorry.