From 08150d95e7ab75d688eb2375d8b166cfed22fcf9 Mon Sep 17 00:00:00 2001 From: Jeremie Deray Date: Mon, 29 Jul 2019 16:08:21 -0400 Subject: [PATCH] Check for fclose returning 0 in rosbag_storage (#1750) fix #1743 --- tools/rosbag_storage/src/chunked_file.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/rosbag_storage/src/chunked_file.cpp b/tools/rosbag_storage/src/chunked_file.cpp index 9eb665826f..dd5e617c5f 100644 --- a/tools/rosbag_storage/src/chunked_file.cpp +++ b/tools/rosbag_storage/src/chunked_file.cpp @@ -100,7 +100,9 @@ void ChunkedFile::open(string const& filename, string const& mode) { file_ = fopen(filename.c_str(), "w+b"); #endif else { - fclose(file_); + if (fclose(file_) != 0) + throw BagIOException((format("Error closing file: %1%") % filename.c_str()).str()); + // open existing file for update #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) fopen_s( &file_, filename.c_str(), "r+b" );