Dmitry Timoshkov : crypt32: Check number of bytes returned by ReadFile and avoid a memory leak on error path .

Alexandre Julliard julliard at winehq.org
Wed Oct 30 13:11:04 CDT 2013


Module: wine
Branch: master
Commit: d95797e17052b5a91373f8ea604365de9b2e5fd2
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d95797e17052b5a91373f8ea604365de9b2e5fd2

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Tue Oct 29 16:08:59 2013 +0900

crypt32: Check number of bytes returned by ReadFile and avoid a memory leak on error path.

---

 dlls/crypt32/filestore.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/dlls/crypt32/filestore.c b/dlls/crypt32/filestore.c
index 44b9bbb..81c8c5e 100644
--- a/dlls/crypt32/filestore.c
+++ b/dlls/crypt32/filestore.c
@@ -119,7 +119,8 @@ static BOOL CRYPT_ReadBlobFromFile(HANDLE file, PCERT_BLOB blob)
         {
             DWORD read;
 
-            ret = ReadFile(file, blob->pbData, blob->cbData, &read, NULL);
+            ret = ReadFile(file, blob->pbData, blob->cbData, &read, NULL) && read == blob->cbData;
+            if (!ret) CryptMemFree(blob->pbData);
         }
     }
     return ret;




More information about the wine-cvs mailing list