libcriu: criu_init_opts: don't leak on rpc and opts

Reported-by: Andrew Vagin <avagin@gmail.com>
Signed-off-by: Ruslan Kuprieiev <kupruser@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Ruslan Kuprieiev 2015-07-21 13:27:00 +03:00 committed by Pavel Emelyanov
parent ba68d61f54
commit de17028a08

View file

@ -61,8 +61,13 @@ int criu_local_init_opts(criu_opts **o)
opts = *o;
if (opts && opts->rpc)
criu_opts__free_unpacked(opts->rpc, NULL);
if (opts) {
if (opts->rpc)
criu_opts__free_unpacked(opts->rpc, NULL);
free(opts);
opts = NULL;
}
rpc = malloc(sizeof(CriuOpts));
if (rpc == NULL) {
@ -75,6 +80,7 @@ int criu_local_init_opts(criu_opts **o)
opts = malloc(sizeof(criu_opts));
if (opts == NULL) {
perror("Can't allocate memory for criu opts");
criu_opts__free_unpacked(rpc, NULL);
return -1;
}