lib/util_hash.c: write directly to malloced string instead if coping it over
This commit is contained in:
parent
df97be6a54
commit
b55ffeceae
@ -132,17 +132,18 @@ xbps_file_hash_raw(const char *file)
|
||||
char *
|
||||
xbps_file_hash(const char *file)
|
||||
{
|
||||
char *res, hash[SHA256_DIGEST_LENGTH * 2 + 1];
|
||||
char *hash;
|
||||
unsigned char *digest;
|
||||
|
||||
if (!(digest = xbps_file_hash_raw(file)))
|
||||
return NULL;
|
||||
|
||||
hash = malloc(SHA256_DIGEST_LENGTH * 2 + 1);
|
||||
assert(hash);
|
||||
digest2string(digest, hash, SHA256_DIGEST_LENGTH);
|
||||
res = strdup(hash);
|
||||
free(digest);
|
||||
|
||||
return res;
|
||||
return hash;
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user