winebus.sys: Fix memory leaks in bus_event_queue functions.

Signed-off-by: Ivo Ivanov <logos128@gmail.com>
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Ivo Ivanov 2021-10-08 12:36:44 +02:00 committed by Alexandre Julliard
parent 5689ec7bba
commit 8f37de5149

View file

@ -329,7 +329,11 @@ BOOL bus_event_queue_device_removed(struct list *queue, struct unix_device *devi
struct bus_event *event = malloc(size);
if (!event) return FALSE;
if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */
if (unix_device_incref(device) == 1) /* being destroyed */
{
free(event);
return FALSE;
}
event->type = BUS_EVENT_TYPE_DEVICE_REMOVED;
event->device = device;
@ -344,7 +348,11 @@ BOOL bus_event_queue_device_created(struct list *queue, struct unix_device *devi
struct bus_event *event = malloc(size);
if (!event) return FALSE;
if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */
if (unix_device_incref(device) == 1) /* being destroyed */
{
free(event);
return FALSE;
}
event->type = BUS_EVENT_TYPE_DEVICE_CREATED;
event->device = device;
@ -360,7 +368,11 @@ BOOL bus_event_queue_input_report(struct list *queue, struct unix_device *device
struct bus_event *event = malloc(size);
if (!event) return FALSE;
if (unix_device_incref(device) == 1) return FALSE; /* being destroyed */
if (unix_device_incref(device) == 1) /* being destroyed */
{
free(event);
return FALSE;
}
event->type = BUS_EVENT_TYPE_INPUT_REPORT;
event->device = device;