fix string length

This commit is contained in:
julian
2023-12-29 16:21:20 -06:00
parent 3e23959e5b
commit b8200b2f99
2 changed files with 1 additions and 5 deletions

View File

@@ -542,11 +542,7 @@ abstract final class LibSpark {
return hashes;
}
/// [x] and [y] must be of length 64
static String hashTag(String x, String y) {
assert(x.length == 64);
assert(y.length == 64);
final xPtr = x.toNativeUtf8().cast<Char>();
final yPtr = y.toNativeUtf8().cast<Char>();

View File

@@ -369,7 +369,7 @@ const char* hashTag(const char* x, const char* y) {
secp_primitives::GroupElement tag = secp_primitives::GroupElement(x, y, 16);
uint256 hash = primitives::GetLTagHash(tag);
std::string hex = hash.GetHex();
char* result = (char*) malloc(sizeof(char) * hex.length());
char* result = (char*) malloc(sizeof(char) * (hex.length() + 1));
strcpy(result, hex.c_str());
return result;
}