diff options
author | Ladislav Zezula <ladislav.zezula@avg.com> | 2015-05-28 13:49:23 +0200 |
---|---|---|
committer | Ladislav Zezula <ladislav.zezula@avg.com> | 2015-05-28 13:49:23 +0200 |
commit | 1b38ceb0d4bb4ae32cb93c295e3ef493b91f9a78 (patch) | |
tree | 5634e1d3fd17386975db1c0d4e95176db098bc1f /src/SFileAddFile.cpp | |
parent | c26e12c79f2a5e0c092de4a62565bdae4bf5a7dd (diff) |
+ Fixed defects found by Coverity (well, most of them)
Diffstat (limited to 'src/SFileAddFile.cpp')
-rw-r--r-- | src/SFileAddFile.cpp | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/src/SFileAddFile.cpp b/src/SFileAddFile.cpp index ea3c5f9..b70eeb1 100644 --- a/src/SFileAddFile.cpp +++ b/src/SFileAddFile.cpp @@ -435,7 +435,7 @@ int SFileAddFile_Init( // Allocate the TMPQFile entry for newly added file hf = CreateWritableHandle(ha, dwFileSize); if(hf == NULL) - nError = GetLastError(); + return false; // Allocate file entry in the MPQ if(nError == ERROR_SUCCESS) @@ -902,26 +902,21 @@ bool WINAPI SFileAddFileEx( // Check parameters if(hMpq == NULL || szFileName == NULL || *szFileName == 0) - nError = ERROR_INVALID_PARAMETER; - - // Open added file - if(nError == ERROR_SUCCESS) { - pStream = FileStream_OpenFile(szFileName, STREAM_FLAG_READ_ONLY | STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE); - if(pStream == NULL) - nError = GetLastError(); + SetLastError(ERROR_INVALID_PARAMETER); + return false; } - // Get the file size and file time - if(nError == ERROR_SUCCESS) - { - FileStream_GetTime(pStream, &FileTime); - FileStream_GetSize(pStream, &FileSize); - - // Files bigger than 4GB cannot be added to MPQ - if(FileSize >> 32) - nError = ERROR_DISK_FULL; - } + // Open added file + pStream = FileStream_OpenFile(szFileName, STREAM_FLAG_READ_ONLY | STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE); + if(pStream == NULL) + return false; + + // Files bigger than 4GB cannot be added to MPQ + FileStream_GetTime(pStream, &FileTime); + FileStream_GetSize(pStream, &FileSize); + if(FileSize >> 32) + nError = ERROR_DISK_FULL; // Allocate data buffer for reading from the source file if(nError == ERROR_SUCCESS) |