2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 05:48:05 +00:00

sk-tcp: fix memory leak

CID 996187 (#1 of 1): Resource leak (RESOURCE_LEAK)
10. leaked_storage: Variable "buf" going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrey Vagin 2013-04-10 00:56:20 +04:00 committed by Pavel Emelyanov
parent 7c02f65b98
commit 17e2daddf2

View File

@ -409,7 +409,7 @@ static int restore_tcp_seqs(int sk, TcpStreamEntry *tse)
static int send_tcp_queue(int sk, int queue, u32 len, int imgfd)
{
int ret;
int ret, err = -1;
char *buf;
pr_debug("\tRestoring TCP %d queue data %u bytes\n", queue, len);
@ -424,19 +424,20 @@ static int send_tcp_queue(int sk, int queue, u32 len, int imgfd)
return -1;
if (read_img_buf(imgfd, buf, len) < 0)
return -1;
goto err;
ret = send(sk, buf, len, 0);
xfree(buf);
if (ret != len) {
pr_perror("Can't restore %d queue data (%d), want %d",
queue, ret, len);
return -1;
goto err;
}
return 0;
err = 0;
err:
xfree(buf);
return err;
}
static int restore_tcp_queues(int sk, TcpStreamEntry *tse, int fd)