summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess_win.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2014-06-05 17:15:03 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-06-12 17:54:11 +0200
commit6ca3ab626a04c3b05e6b3fde9a48457cf89c2889 (patch)
tree656df3d442da9539b2757b21cf6b045d0468f800 /src/corelib/io/qprocess_win.cpp
parent25ef58fe185f1534d9d89aee72e84c3789068907 (diff)
Don't try to read from invalid file descriptors in QProcess
strace reveals that we do ioctl(-1, FIONREAD) and get EBADF. The only case where this could happen is inside _q_processDied, which calls the read functions without checking if the pipe is still open. Change-Id: I67637fc4267be73fc03d40c444fdfea89e1ef715 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Diffstat (limited to 'src/corelib/io/qprocess_win.cpp')
-rw-r--r--src/corelib/io/qprocess_win.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp
index 2dd4c475d8..7b3f1f8f58 100644
--- a/src/corelib/io/qprocess_win.cpp
+++ b/src/corelib/io/qprocess_win.cpp
@@ -566,11 +566,8 @@ bool QProcessPrivate::processStarted()
qint64 QProcessPrivate::bytesAvailableInChannel(const Channel *channel) const
{
- if (channel->pipe[0] == INVALID_Q_PIPE)
- return 0;
-
- if (!channel->reader)
- return 0;
+ Q_ASSERT(channel->pipe[0] != INVALID_Q_PIPE);
+ Q_ASSERT(channel->reader);
DWORD bytesAvail = channel->reader->bytesAvailable();
#if defined QPROCESS_DEBUG
@@ -581,7 +578,9 @@ qint64 QProcessPrivate::bytesAvailableInChannel(const Channel *channel) const
qint64 QProcessPrivate::readFromChannel(const Channel *channel, char *data, qint64 maxlen)
{
- return channel->reader ? channel->reader->read(data, maxlen) : 0;
+ Q_ASSERT(channel->pipe[0] != INVALID_Q_PIPE);
+ Q_ASSERT(channel->reader);
+ return channel->reader->read(data, maxlen);
}
static BOOL QT_WIN_CALLBACK qt_terminateApp(HWND hwnd, LPARAM procId)