]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Don't try to close negative file descriptors, since this can cause
authorMagnus Hagander <magnus@hagander.net>
Tue, 13 May 2008 20:53:54 +0000 (20:53 +0000)
committerMagnus Hagander <magnus@hagander.net>
Tue, 13 May 2008 20:53:54 +0000 (20:53 +0000)
crashes on certain platforms. In particular, the MSVC runtime is known
to do this.

Fixes bug #4162, reported and diagnosed by Javier Pimas

src/backend/access/transam/xlog.c

index 5a1027507502624d8ccf7b89c467bbef2531ad8b..873e450571173cb8881bc331b1cf6d73fd2ed33b 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.125.2.4 2006/01/05 00:55:23 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.125.2.5 2008/05/13 20:53:54 mha Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2056,8 +2056,11 @@ got_record:;
        return (XLogRecord *) buffer;
 
 next_record_is_invalid:;
-       close(readFile);
-       readFile = -1;
+       if (readFile >= 0)
+       {
+               close(readFile);
+               readFile = -1;
+       }
        nextRecord = NULL;
        return NULL;
 }