VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2014-07-09 12:55:46 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2014-11-08 23:20:48 +0100
commit7bb812af66967a0c942f130cc94c25341e17950a (patch)
treec3e11587541206803c11c4bcfff435ea832cf117 /src/Common
parent9d027b02b9723493f66b94bba648e20d48e73b6f (diff)
downloadVeraCrypt-7bb812af66967a0c942f130cc94c25341e17950a.tar.gz
VeraCrypt-7bb812af66967a0c942f130cc94c25341e17950a.zip
Static Code Analysis : Avoid using invalidate integer value received from GetFileSize.
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/Dlgcode.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 084e93d5..d8ed1bc2 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -7420,11 +7420,15 @@ fsif_end:
char *LoadFile (const char *fileName, DWORD *size)
{
char *buf;
+ DWORD fileSize = INVALID_FILE_SIZE;
HANDLE h = CreateFile (fileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
if (h == INVALID_HANDLE_VALUE)
return NULL;
- *size = GetFileSize (h, NULL);
+ if ((fileSize = GetFileSize (h, NULL)) == INVALID_FILE_SIZE)
+ return NULL;
+
+ *size = fileSize;
buf = (char *) calloc (*size + 1, 1);
if (buf == NULL)