Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crypto.js does not implement the _free function: function _free() { } #13

Open
will-yjn opened this issue Jul 15, 2022 · 0 comments
Open

Comments

@will-yjn
Copy link

https://github.com/luigi1111/xmr.llcoins.net/blob/master/site/js/crypto.js

In the crypto.js file, the _free function is not implemented. Right?

It seems this causes a bug:

function sc_reduce32(hex) {
    var input = hextobin(hex);
    if (input?.length !== 32) {
        throw "Invalid input length";
    }
    // Module._malloc() return the address of the alloced memory - the pointer
    var mem = Module._malloc(32);
    Module.HEAPU8.set(input, mem);
    Module.ccall('sc_reduce32', 'void', ['number'], [mem]);
    var output = Module.HEAPU8.subarray(mem, mem + 32);
    Module._free(mem);
    return bintohex(output);
};

In the above snippet of code, since the memory is not actually freed, so if you run this function, say 10k times, then the crypto.js will throw an error:

Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 16777216, (2) compile with ALLOW_MEMORY_GROWTH which adjusts the size at runtime but prevents some optimizations, or (3) set Module.TOTAL_MEMORY before the program runs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant