lib/util_hash.c: fix memleak.
This commit is contained in:
parent
35fa3b5808
commit
842ac7c97e
@ -123,10 +123,12 @@ xbps_file_hash_raw(const char *file)
|
|||||||
SHA256_Init(&sha256);
|
SHA256_Init(&sha256);
|
||||||
while ((len = read(fd, buf, sizeof(buf))) > 0)
|
while ((len = read(fd, buf, sizeof(buf))) > 0)
|
||||||
SHA256_Update(&sha256, buf, len);
|
SHA256_Update(&sha256, buf, len);
|
||||||
|
if(len < 0) {
|
||||||
|
free(digest);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
SHA256_Final(digest, &sha256);
|
SHA256_Final(digest, &sha256);
|
||||||
(void)close(fd);
|
(void)close(fd);
|
||||||
if(len < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return digest;
|
return digest;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user