From 5ffab7f2784fef5c0ab05a81c0fb693c7fe1426f Mon Sep 17 00:00:00 2001 From: Brian Cox Date: Mon, 9 May 2016 10:34:53 -0700 Subject: [PATCH] Only posix_fadvise() on close if stream is nonnull, since fileno() segfaults (on Linux) if you try that. --- src/core/file_unix.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/file_unix.cpp b/src/core/file_unix.cpp index 5526025..c969398 100644 --- a/src/core/file_unix.cpp +++ b/src/core/file_unix.cpp @@ -1,4 +1,4 @@ -// + // The developer of the original code and/or files is Tripwire, Inc. // Portions created by Tripwire, Inc. are copyright (C) 2000 Tripwire, // Inc. Tripwire is a registered trademark of Tripwire, Inc. All rights @@ -229,12 +229,12 @@ void cFile::Open( const TSTRING& sFileNameC, uint32 flags ) /////////////////////////////////////////////////////////////////////////// void cFile::Close() //throw(eFile) { -#ifdef HAVE_POSIX_FADVISE - posix_fadvise(fileno(mpData->mpCurrStream),0,0, POSIX_FADV_DONTNEED); -#endif - if(mpData->mpCurrStream != NULL) { +#ifdef HAVE_POSIX_FADVISE + posix_fadvise(fileno(mpData->mpCurrStream),0,0, POSIX_FADV_DONTNEED); +#endif + fclose( mpData->mpCurrStream ); mpData->mpCurrStream = NULL; }