mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-03-23 07:20:38 +01:00
Don't leak when realloc fails
Found by coverity Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
da94e4e603
commit
075e998b07
1 changed files with 6 additions and 2 deletions
|
|
@ -2735,15 +2735,19 @@ libinput_post_event(struct libinput *libinput,
|
|||
|
||||
events_count++;
|
||||
if (events_count > events_len) {
|
||||
void *tmp;
|
||||
|
||||
events_len *= 2;
|
||||
events = realloc(events, events_len * sizeof *events);
|
||||
if (!events) {
|
||||
tmp = realloc(events, events_len * sizeof *events);
|
||||
if (!tmp) {
|
||||
log_error(libinput,
|
||||
"Failed to reallocate event ring buffer. "
|
||||
"Events may be discarded\n");
|
||||
return;
|
||||
}
|
||||
|
||||
events = tmp;
|
||||
|
||||
if (libinput->events_count > 0 && libinput->events_in == 0) {
|
||||
libinput->events_in = libinput->events_len;
|
||||
} else if (libinput->events_count > 0 &&
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue