Don't try to close negative file descriptors, since this can cause
authorMagnus Hagander <magnus@hagander.net>
Tue, 13 May 2008 20:54:02 +0000 (20:54 +0000)
committerMagnus Hagander <magnus@hagander.net>
Tue, 13 May 2008 20:54:02 +0000 (20:54 +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 67541fce24fced9b48898cffa91f48530b3972ab..e43cf467fa442d6354f65198c5c8e6daab31172c 100644 (file)
@@ -3317,8 +3317,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;
 }