mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-21 01:06:58 +00:00
uffd: handle xrealloc() failure
In the case, that xrealloc() fails do not overwrite the original pointer to be able to free the original pointer on exit. Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
parent
56a70ff99b
commit
528ce25987
1 changed files with 4 additions and 2 deletions
|
|
@ -1131,6 +1131,7 @@ out:
|
|||
static int complete_forks(int epollfd, struct epoll_event **events, int *nr_fds)
|
||||
{
|
||||
struct lazy_pages_info *lpi, *n;
|
||||
struct epoll_event *tmp;
|
||||
|
||||
if (list_empty(&pending_lpis))
|
||||
return 1;
|
||||
|
|
@ -1138,9 +1139,10 @@ static int complete_forks(int epollfd, struct epoll_event **events, int *nr_fds)
|
|||
list_for_each_entry(lpi, &pending_lpis, l)
|
||||
(*nr_fds)++;
|
||||
|
||||
*events = xrealloc(*events, sizeof(struct epoll_event) * (*nr_fds));
|
||||
if (!*events)
|
||||
tmp = xrealloc(*events, sizeof(struct epoll_event) * (*nr_fds));
|
||||
if (!tmp)
|
||||
return -1;
|
||||
*events = tmp;
|
||||
|
||||
list_for_each_entry_safe(lpi, n, &pending_lpis, l) {
|
||||
if (epoll_add_rfd(epollfd, &lpi->lpfd))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue