Don't try to close negative file descriptors, since this can cause
authorMagnus Hagander <[email protected]>
Tue, 13 May 2008 20:53:58 +0000 (20:53 +0000)
committerMagnus Hagander <[email protected]>
Tue, 13 May 2008 20:53:58 +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 fb958cc7eebea173c076255f80cdf494efe6191d..288936eb65067320c556604d8365f69f1d9cbec7 100644 (file)
@@ -2934,8 +2934,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;
 }