Merge pull request #343 from svost/c++11
authorCryptoManiac <CryptoManiac@users.noreply.github.com>
Wed, 4 May 2016 15:43:56 +0000 (19:43 +0400)
committerCryptoManiac <CryptoManiac@users.noreply.github.com>
Wed, 4 May 2016 15:43:56 +0000 (19:43 +0400)
Minor fix: c++11 branch

src/util.cpp

index 744717c..1500e0f 100644 (file)
@@ -1246,8 +1246,9 @@ void ShrinkDebugFile()
         // Restart the file with some of the end
         try {
             vector<char>* vBuf = new vector <char>(200000, 0);
-            fseek(file, -((long)(vBuf->size())), SEEK_END);
-            size_t nBytes = fread(&vBuf->operator[](0), 1, vBuf->size(), file);
+            size_t nBytes = 1; //write one byte if fseek failed
+            if (fseek(file, -((long)(vBuf->size())), SEEK_END) == 0)
+                nBytes = fread(&vBuf->operator[](0), 1, vBuf->size(), file);
             fclose(file);
             file = fopen(pathLog.string().c_str(), "w");
             if (file)