summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qnativesocketengine_unix.cpp
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-09-20 18:22:59 +0200
committerGiuseppe D'Angelo <giuseppe.dangelo@kdab.com>2014-09-22 14:08:57 +0200
commit87fbfe074bf78506b3994ccd5c1c4b82ce2b6a71 (patch)
treeb2813d15519ef52b0761bb8c9aefbc881b99aff2 /src/network/socket/qnativesocketengine_unix.cpp
parent5d688c5780b2b7e61630e26100f0932d33513291 (diff)
Fix a mishandling of the fd returned by socket(2)
socket(2) is allowed to return 0, so 0 should not be included when checking for errors. Change-Id: I0454ea60347d90078d3ab3046969add8d5c37935 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Richard J. Moore <rich@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/network/socket/qnativesocketengine_unix.cpp')
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index 65244ce9cf..ebfb2a2793 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -147,13 +147,13 @@ bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType soc
int type = (socketType == QAbstractSocket::UdpSocket) ? SOCK_DGRAM : SOCK_STREAM;
int socket = qt_safe_socket(protocol, type, 0);
- if (socket <= 0 && socketProtocol == QAbstractSocket::AnyIPProtocol && errno == EAFNOSUPPORT) {
+ if (socket < 0 && socketProtocol == QAbstractSocket::AnyIPProtocol && errno == EAFNOSUPPORT) {
protocol = AF_INET;
socket = qt_safe_socket(protocol, type, 0);
socketProtocol = QAbstractSocket::IPv4Protocol;
}
- if (socket <= 0) {
+ if (socket < 0) {
switch (errno) {
case EPROTONOSUPPORT:
case EAFNOSUPPORT: