heap corruption?

This commit is contained in:
Denis 2023-12-08 01:27:48 +01:00
parent dc06046f7c
commit 55125bb3ce
No known key found for this signature in database
GPG key ID: DD9B63F805CF5C03
3 changed files with 8 additions and 6 deletions

View file

@ -56,7 +56,7 @@ void dev_evdev_close(struct libevdev* out_evdev) {
int dev_evdev_open(
const uinput_filters_t *const in_filters,
struct libevdev* out_evdev
struct libevdev* *const out_evdev
) {
int res = -ENOENT;
@ -114,7 +114,7 @@ int dev_evdev_open(
open_fds[open_sysfs_idx] = fd;
}
if (libevdev_new_from_fd(fd, &out_evdev) != 0) {
if (libevdev_new_from_fd(fd, out_evdev) != 0) {
fprintf(stderr, "Cannot initialize libevdev from this device (%s) -- Skipping.\n", path);
open_fds[open_sysfs_idx] = -1;
close(fd);
@ -122,11 +122,13 @@ int dev_evdev_open(
}
// try to open the device
if (!ev_matches(out_evdev, in_filters)) {
libevdev_free(out_evdev);
if (!ev_matches(*out_evdev, in_filters)) {
libevdev_free(*out_evdev);
open_fds[open_sysfs_idx] = -1;
close(fd);
continue;
} else {
printf("post-ev_matches: %s\n", libevdev_get_name(*out_evdev));
}
// the device has been found

View file

@ -4,7 +4,7 @@
int dev_evdev_open(
const uinput_filters_t *const in_filters,
struct libevdev* out_evdev
struct libevdev* *const out_evdev
);
void dev_evdev_close(struct libevdev* out_evdev);

View file

@ -100,7 +100,7 @@ int open_device(
const uinput_filters_t *const in_filters,
dev_in_ev_t *const out_dev
) {
int res = dev_evdev_open(in_filters, out_dev->evdev);
int res = dev_evdev_open(in_filters, &out_dev->evdev);
if (res != 0) {
fprintf(stderr, "Unable to open the specified device: %d\n", res);
goto open_device_err;