mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-05 15:48:02 +02:00
tools: libinput-record: fix leaking memory in the error cases
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
75e4ab05e4
commit
7ad3dcf939
1 changed files with 7 additions and 3 deletions
|
|
@ -2068,7 +2068,7 @@ init_device(struct record_context *ctx, char *path)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Failed to open device %s (%m)\n",
|
"Failed to open device %s (%m)\n",
|
||||||
d->devnode);
|
d->devnode);
|
||||||
return false;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = libevdev_new_from_fd(fd, &d->evdev);
|
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",
|
"Failed to create context for %s (%s)\n",
|
||||||
d->devnode,
|
d->devnode,
|
||||||
strerror(-rc));
|
strerror(-rc));
|
||||||
close(fd);
|
goto error;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
libevdev_set_clock_id(d->evdev, CLOCK_MONOTONIC);
|
libevdev_set_clock_id(d->evdev, CLOCK_MONOTONIC);
|
||||||
|
|
@ -2090,6 +2089,11 @@ init_device(struct record_context *ctx, char *path)
|
||||||
ctx->ndevices++;
|
ctx->ndevices++;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
error:
|
||||||
|
close(fd);
|
||||||
|
free(d);
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
static int
|
static int
|
||||||
open_restricted(const char *path, int flags, void *user_data)
|
open_restricted(const char *path, int flags, void *user_data)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue