summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2018-05-11 15:04:22 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2018-05-16 14:23:12 +1000
commit7ad3dcf939da289cd551e735e045e34d69baddec (patch)
tree3dd3facb7f12bf7fc804148abd2e9ba81db37d22 /tools
parent75e4ab05e44c0bdccc91444ad0eff08b36ad0d03 (diff)
tools: libinput-record: fix leaking memory in the error cases
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/libinput-record.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/tools/libinput-record.c b/tools/libinput-record.c
index f0a41058..18b653c5 100644
--- a/tools/libinput-record.c
+++ b/tools/libinput-record.c
@@ -2068,7 +2068,7 @@ init_device(struct record_context *ctx, char *path)
fprintf(stderr,
"Failed to open device %s (%m)\n",
d->devnode);
- return false;
+ goto error;
}
rc = libevdev_new_from_fd(fd, &d->evdev);
@@ -2077,8 +2077,7 @@ init_device(struct record_context *ctx, char *path)
"Failed to create context for %s (%s)\n",
d->devnode,
strerror(-rc));
- close(fd);
- return false;
+ goto error;
}
libevdev_set_clock_id(d->evdev, CLOCK_MONOTONIC);
@@ -2090,6 +2089,11 @@ init_device(struct record_context *ctx, char *path)
ctx->ndevices++;
return true;
+error:
+ close(fd);
+ free(d);
+ return false;
+
}
static int
open_restricted(const char *path, int flags, void *user_data)