diff --git a/source/crypto.c b/source/crypto.c index 4fb963e2..b84cfe22 100644 --- a/source/crypto.c +++ b/source/crypto.c @@ -109,12 +109,11 @@ static JSValue nx_crypto_sha256_hex(JSContext *ctx, JSValueConst this_val, } sha256CalculateHash(digest, str, size); JS_FreeCString(ctx, str); - char *hex = js_malloc(ctx, (SHA256_HASH_SIZE * 2) + 1); + char hex[SHA256_HASH_SIZE * 2 + 1]; for (int i = 0; i < SHA256_HASH_SIZE; i++) { snprintf(hex + i * 2, 3, "%02x", digest[i]); } JSValue hex_val = JS_NewString(ctx, hex); - js_free(ctx, hex); js_free(ctx, digest); return hex_val; }