mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
Use calloc directly instead of combining malloc and ZeroMemory
This commit is contained in:
@@ -7404,7 +7404,7 @@ char *LoadFile (const char *fileName, DWORD *size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
*size = GetFileSize (h, NULL);
|
*size = GetFileSize (h, NULL);
|
||||||
buf = (char *) malloc (*size + 1);
|
buf = (char *) calloc (*size + 1, 1);
|
||||||
|
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
{
|
{
|
||||||
@@ -7412,8 +7412,6 @@ char *LoadFile (const char *fileName, DWORD *size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroMemory (buf, *size + 1);
|
|
||||||
|
|
||||||
if (!ReadFile (h, buf, *size, size, NULL))
|
if (!ReadFile (h, buf, *size, size, NULL))
|
||||||
{
|
{
|
||||||
free (buf);
|
free (buf);
|
||||||
@@ -7444,7 +7442,7 @@ char *LoadFileBlock (char *fileName, __int64 fileOffset, size_t count)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = (char *) malloc (count);
|
buf = (char *) calloc (count, 1);
|
||||||
|
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
{
|
{
|
||||||
@@ -7452,10 +7450,7 @@ char *LoadFileBlock (char *fileName, __int64 fileOffset, size_t count)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZeroMemory (buf, count);
|
ReadFile (h, buf, count, &bytesRead, NULL);
|
||||||
|
|
||||||
if (buf != NULL)
|
|
||||||
ReadFile (h, buf, count, &bytesRead, NULL);
|
|
||||||
|
|
||||||
CloseHandle (h);
|
CloseHandle (h);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user