summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorLu Zhen <luzhen@uniontech.com>2021-01-12 20:37:05 +0800
committerLars Knoll <lars.knoll@qt.io>2021-01-14 09:47:07 +0000
commitcb4f853cb05bd57c0a00d9ca41b7e30bdd13bf9a (patch)
tree5342f1e3340735d72cbe8df8e5baf91aac17ca6f /src/corelib/io
parentc2657f9762e01abd65ac991ba31e3ca085d9540c (diff)
Add some error handling for the inotify file system watcher
In the readFromInotify() function, add a check whether the ioctl function is successful or not. In the case of failure, continuing to execute the following code would cause errors in the read function because there is no data in the buffer. Change-Id: Id53037e9e48c97c9eb75835048143875275b6370 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qfilesystemwatcher_inotify.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp
index 94d9d06bcb..68e5ab7fa4 100644
--- a/src/corelib/io/qfilesystemwatcher_inotify.cpp
+++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp
@@ -366,7 +366,9 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
// qDebug("QInotifyFileSystemWatcherEngine::readFromInotify");
int buffSize = 0;
- ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
+ if (ioctl(inotifyFd, FIONREAD, (char *) &buffSize) == -1)
+ return;
+
QVarLengthArray<char, 4096> buffer(buffSize);
buffSize = read(inotifyFd, buffer.data(), buffSize);
char *at = buffer.data();