summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhondres <liu.gam3@gmail.com>2016-02-01 13:39:50 +0100
committerhondres <liu.gam3@gmail.com>2016-02-01 13:39:50 +0100
commit2809b31f8c7b87a020d2c8f4750d3652176b936d (patch)
treeeac262a72f53cbdefb965a614c67f748efbb797e
parent0364d6b076cfc4e75985731b67f8155bf173dd06 (diff)
close file descriptor if ioctls failed
-rw-r--r--platform/x11/joystick_linux.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/platform/x11/joystick_linux.cpp b/platform/x11/joystick_linux.cpp
index 5007976f0d..208bb2a2b7 100644
--- a/platform/x11/joystick_linux.cpp
+++ b/platform/x11/joystick_linux.cpp
@@ -304,6 +304,7 @@ void joystick_linux::open_joystick(const char *p_path) {
if ((ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), evbit) < 0) ||
(ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) ||
(ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) < 0)) {
+ close(fd);
return;
}