From 6c8d6127d29266310ee797a19f3388ca7daadd92 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Tue, 1 Dec 2009 10:54:23 +0100 Subject: Make sure file descriptors are valid in the dnotify implementation of QFileSystemWatcher Commit 71c3227ba260b964b0c9516f05ad4f2e6fa72f69 fixed a memory leak by calling closedir(), which would also close the file descriptor we were wanting to watch. Fix this by duplicating the file descriptor that we store. Reviewed-by: TrustMe --- src/corelib/io/qfilesystemwatcher_dnotify.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/io/qfilesystemwatcher_dnotify.cpp b/src/corelib/io/qfilesystemwatcher_dnotify.cpp index 03172e5..1fab010 100644 --- a/src/corelib/io/qfilesystemwatcher_dnotify.cpp +++ b/src/corelib/io/qfilesystemwatcher_dnotify.cpp @@ -269,8 +269,8 @@ QStringList QDnotifyFileSystemWatcherEngine::addPaths(const QStringList &paths, } } - fd = ::dirfd(d); - int parentFd = parent?::dirfd(parent):0; + fd = qt_safe_dup(::dirfd(d)); + int parentFd = parent ? qt_safe_dup(::dirfd(parent)) : 0; Q_ASSERT(fd); if(::fcntl(fd, F_SETSIG, SIGIO) || -- cgit v0.12