crashes on certain platforms. In particular, the MSVC runtime is known
to do this.
Fixes bug #4162, reported and diagnosed by Javier Pimas
  * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.292.2.3 2008/05/09 15:28:01 heikki Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.292.2.4 2008/05/13 20:54:02 mha Exp $
  *
  *-------------------------------------------------------------------------
  */
    return (XLogRecord *) buffer;
 
 next_record_is_invalid:;
-   close(readFile);
-   readFile = -1;
+   if (readFile >= 0)
+   {
+       close(readFile);
+       readFile = -1;
+   }
    nextRecord = NULL;
    return NULL;
 }