Skip to content

Commit

Permalink
hex on stack
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Jul 11, 2024
1 parent 7c9044e commit 9cb2b4f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions source/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9cb2b4f

Please sign in to comment.