Skip to content

Commit

Permalink
Allocate null terminator
Browse files Browse the repository at this point in the history
  • Loading branch information
TooTallNate committed Jul 10, 2024
1 parent c67770e commit 014fbb1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ 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);
char *hex = js_malloc(ctx, (SHA256_HASH_SIZE * 2) + 1);
for (int i = 0; i < SHA256_HASH_SIZE; i++) {
snprintf(hex + i * 2, 3, "%02x", digest[i]);
}
Expand Down

0 comments on commit 014fbb1

Please sign in to comment.