From 7bb812af66967a0c942f130cc94c25341e17950a Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Wed, 9 Jul 2014 12:55:46 +0200 Subject: Static Code Analysis : Avoid using invalidate integer value received from GetFileSize. --- src/Common/Dlgcode.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') 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) -- cgit v1.2.3