I have encountered an issue while working with a DLL using js-ctypes, which is written in C.
After calling the method that returns a string and trying to access the content of the pointer, Firefox crashes!
The following code snippet works perfectly:
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 is:
ctypes.char.ptr(ctypes.UInt64("0x64ff5b48"))
However, this other code does not work as expected:
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 remains the same:
ctypes.char.ptr(ctypes.UInt64("0x64ff5b48"))
This approach causes Firefox to crash. Has anyone encountered a similar issue or know how to resolve it? I need assistance with this for my addon development.