From 29c9bdcc141afb14fc9e1213f49de4fcded6ce0c Mon Sep 17 00:00:00 2001 From: practicalswift Date: Wed, 2 May 2018 12:12:55 +0200 Subject: Handle unsuccessful fseek(...):s --- src/logging.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/logging.cpp') diff --git a/src/logging.cpp b/src/logging.cpp index 10a3b18958..2a55d3665b 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -254,7 +254,10 @@ void BCLog::Logger::ShrinkDebugFile() { // Restart the file with some of the end std::vector vch(RECENT_DEBUG_HISTORY_SIZE, 0); - fseek(file, -((long)vch.size()), SEEK_END); + if (fseek(file, -((long)vch.size()), SEEK_END)) { + fclose(file); + return; + } int nBytes = fread(vch.data(), 1, vch.size(), file); fclose(file); -- cgit v1.2.3 From 20ce5af4c647d9ebd97b40683bd0747383c9dc20 Mon Sep 17 00:00:00 2001 From: practicalswift Date: Thu, 3 May 2018 15:44:04 +0200 Subject: Print a log message if we fail to shrink the debug log file --- src/logging.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/logging.cpp') diff --git a/src/logging.cpp b/src/logging.cpp index 2a55d3665b..87756fb4cc 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -255,6 +255,7 @@ void BCLog::Logger::ShrinkDebugFile() // Restart the file with some of the end std::vector vch(RECENT_DEBUG_HISTORY_SIZE, 0); if (fseek(file, -((long)vch.size()), SEEK_END)) { + LogPrintf("Failed to shrink debug log file: fseek(...) failed\n"); fclose(file); return; } -- cgit v1.2.3