summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorAleksandar Sasha Babic <aleksandar.babic@nokia.com>2009-05-18 07:23:41 (GMT)
committerAleksandar Sasha Babic <aleksandar.babic@nokia.com>2009-05-18 07:23:41 (GMT)
commitccab28c0a778d5e951ff9d6c9bb5f74fc1a2d97c (patch)
treeab91ff1da01998c244d0907d7db6c3b6652f6e15 /src/network
parent4592301363ad625e583b76b2f46f616486e5d0d6 (diff)
downloadQt-ccab28c0a778d5e951ff9d6c9bb5f74fc1a2d97c.zip
Qt-ccab28c0a778d5e951ff9d6c9bb5f74fc1a2d97c.tar.gz
Qt-ccab28c0a778d5e951ff9d6c9bb5f74fc1a2d97c.tar.bz2
We should check if socket descriptor is valid before calling other
functions.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index e000e11..21059b1 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -518,8 +518,14 @@ int QNativeSocketEnginePrivate::nativeAccept()
#if defined (QNATIVESOCKETENGINE_DEBUG)
qDebug("QNativeSocketEnginePrivate::nativeAccept() == %i", acceptedDescriptor);
#endif
- // Ensure that the socket is closed on exec*()
- qt_socket_fcntl(acceptedDescriptor, F_SETFD, FD_CLOEXEC);
+
+ //check if we have vaild descriptor at all
+ if(acceptedDescriptor > 0) {
+ // Ensure that the socket is closed on exec*()
+ qt_socket_fcntl(acceptedDescriptor, F_SETFD, FD_CLOEXEC);
+ } else {
+ qWarning("QNativeSocketEnginePrivate::nativeAccept() - acceptedDescriptor <= 0");
+ }
return acceptedDescriptor;
}