mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-22 09:29:52 +03:00
Merge PR #1280: hamcorebuilder: Fix possible resource leak found by Coverity
This commit is contained in:
commit
d161b75a7d
@ -80,15 +80,16 @@ bool BuildHamcore(const char *dst, const char *src)
|
||||
}
|
||||
|
||||
uint8_t *content = malloc(file->OriginalSize);
|
||||
if (!FileRead(handle, content, file->OriginalSize))
|
||||
int ret = FileRead(handle, content, file->OriginalSize);
|
||||
FileClose(handle);
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
printf("FileRead() failed for \"%s\", skipping...\n", path);
|
||||
free(content);
|
||||
continue;
|
||||
}
|
||||
|
||||
FileClose(handle);
|
||||
|
||||
const size_t wanted_size = CompressionBufferSize(file->OriginalSize);
|
||||
if (buffer_size < wanted_size)
|
||||
{
|
||||
@ -99,7 +100,7 @@ bool BuildHamcore(const char *dst, const char *src)
|
||||
}
|
||||
|
||||
file->Size = buffer_size;
|
||||
const int ret = compress(buffer, (uLongf *)&file->Size, content, (uLong)file->OriginalSize);
|
||||
ret = compress(buffer, (uLongf *)&file->Size, content, (uLong)file->OriginalSize);
|
||||
free(content);
|
||||
|
||||
if (ret != Z_OK)
|
||||
|
Loading…
Reference in New Issue
Block a user