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>
This commit is contained in:
Giuseppe D'Angelo 2014-09-20 18:22:59 +02:00
parent 5d688c5780
commit 87fbfe074b

View File

@ -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: