summaryrefslogtreecommitdiffstats
path: root/src/plugins/bearer/generic
diff options
context:
space:
mode:
authorAaron McCarthy <aaron.mccarthy@nokia.com>2010-02-25 22:30:25 (GMT)
committerAaron McCarthy <aaron.mccarthy@nokia.com>2010-02-25 22:30:25 (GMT)
commitf17ba38d5380e458b50ae543b34c52b2a2df8e7e (patch)
tree0cac7319139f06c154ff54c9c51975b797a621fc /src/plugins/bearer/generic
parent4d615766184e3eeee25ffc634847bec1edd47ac0 (diff)
downloadQt-f17ba38d5380e458b50ae543b34c52b2a2df8e7e.zip
Qt-f17ba38d5380e458b50ae543b34c52b2a2df8e7e.tar.gz
Qt-f17ba38d5380e458b50ae543b34c52b2a2df8e7e.tar.bz2
Fix file descriptor leak with generic engine on Linux.
Diffstat (limited to 'src/plugins/bearer/generic')
-rw-r--r--src/plugins/bearer/generic/qgenericengine.cpp11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp
index a95b14b..ccf1057 100644
--- a/src/plugins/bearer/generic/qgenericengine.cpp
+++ b/src/plugins/bearer/generic/qgenericengine.cpp
@@ -125,14 +125,11 @@ static QString qGetInterfaceType(const QString &interface)
ifreq request;
strncpy(request.ifr_name, interface.toLocal8Bit().data(), sizeof(request.ifr_name));
- if (ioctl(sock, SIOCGIFHWADDR, &request) >= 0) {
- switch (request.ifr_hwaddr.sa_family) {
- case ARPHRD_ETHER:
- return QLatin1String("Ethernet");
- }
- }
-
+ int result = ioctl(sock, SIOCGIFHWADDR, &request);
close(sock);
+
+ if (result >= 0 && request.ifr_hwaddr.sa_family == ARPHRD_ETHER)
+ return QLatin1String("Ethernet");
#else
Q_UNUSED(interface);
#endif