From c48a16664b521bbcaa0fa60e37ae65b49202b168 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Wed, 25 Jul 2012 18:05:42 -0500 Subject: [PATCH] Fix double close() in FilerSerializer class. --- src/Serializer.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Serializer.cc b/src/Serializer.cc index 06bbf73f48..97ee8f743c 100644 --- a/src/Serializer.cc +++ b/src/Serializer.cc @@ -742,9 +742,10 @@ FileSerializer::~FileSerializer() io->Flush(); delete [] file; - delete io; - if ( fd >= 0 ) + if ( io ) + delete io; // destructor will call close() on fd + else if ( fd >= 0 ) close(fd); } @@ -808,7 +809,7 @@ void FileSerializer::CloseFile() if ( io ) io->Flush(); - if ( fd >= 0 ) + if ( fd >= 0 && ! io ) // destructor of io calls close() on fd close(fd); fd = -1;