From 60cce948bc8419c15a7fe8ab9669f4ae87c5ef76 Mon Sep 17 00:00:00 2001 From: Andrei Karas <akaras@inbox.ru> Date: Sun, 3 Mar 2013 00:35:26 +0300 Subject: another fixes from Coverity checks. --- src/net/download.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'src/net') diff --git a/src/net/download.cpp b/src/net/download.cpp index 32625b181..2124736ca 100644 --- a/src/net/download.cpp +++ b/src/net/download.cpp @@ -286,7 +286,11 @@ int Download::downloadThread(void *ptr) if (!d->mOptions.memoryWrite) { - fclose(file); + if (file) + { + fclose(file); + file = nullptr; + } ::remove(outFilename.c_str()); } attempts++; @@ -305,7 +309,11 @@ int Download::downloadThread(void *ptr) if (d->mAdler != adler) { - fclose(file); + if (file) + { + fclose(file); + file = nullptr; + } // Remove the corrupted file ::remove(d->mFileName.c_str()); @@ -316,7 +324,11 @@ int Download::downloadThread(void *ptr) continue; // Bail out here to avoid the renaming } } - fclose(file); + if (file) + { + fclose(file); + file = nullptr; + } // Any existing file with this name is deleted first, otherwise // the rename will fail on Windows. @@ -331,6 +343,7 @@ int Download::downloadThread(void *ptr) if (file) { fclose(file); + file = nullptr; complete = true; } } -- cgit v1.2.3-70-g09d2