mirror of
https://github.com/SoftEtherVPN/SoftEtherVPN.git
synced 2024-11-22 17:39:53 +03:00
hamcorebuilder: Fix possible resource leak found by Coverity
FileClose() was not called if FileRead() failed.
This commit is contained in:
parent
809f891f0c
commit
621fb087f8
@ -80,15 +80,16 @@ bool BuildHamcore(const char *dst, const char *src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *content = malloc(file->OriginalSize);
|
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);
|
printf("FileRead() failed for \"%s\", skipping...\n", path);
|
||||||
free(content);
|
free(content);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileClose(handle);
|
|
||||||
|
|
||||||
const size_t wanted_size = CompressionBufferSize(file->OriginalSize);
|
const size_t wanted_size = CompressionBufferSize(file->OriginalSize);
|
||||||
if (buffer_size < wanted_size)
|
if (buffer_size < wanted_size)
|
||||||
{
|
{
|
||||||
@ -99,7 +100,7 @@ bool BuildHamcore(const char *dst, const char *src)
|
|||||||
}
|
}
|
||||||
|
|
||||||
file->Size = buffer_size;
|
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);
|
free(content);
|
||||||
|
|
||||||
if (ret != Z_OK)
|
if (ret != Z_OK)
|
||||||
|
Loading…
Reference in New Issue
Block a user