Changeset: 688e8f04fe26 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=688e8f04fe26
Modified Files:
        gdk/gdk_posix.c
Branch: Oct2012
Log Message:

Accept any valid file descriptor from open, and always close it again.
Found by Coverity.


diffs (22 lines):

diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -367,16 +367,15 @@ MT_mmap(const char *path, int mode, off_
        int fd = open(path, O_CREAT | ((mode & MMAP_WRITE) ? O_RDWR : 
O_RDONLY), MONETDB_MODE);
        void *ret = (void *) -1L;
 
-       if (fd > 1) {
+       if (fd >= 0) {
                ret = mmap(NULL,
                           len,
                           ((mode & MMAP_WRITABLE) ? PROT_WRITE : 0) | 
PROT_READ,
                           (mode & MMAP_COPY) ? (MAP_PRIVATE | MAP_NORESERVE) : 
MAP_SHARED,
                           fd,
                           off);
+               close(fd);
        }
-       if (fd > 0)
-               close(fd);
        return ret;
 }
 
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to