mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
compel: Don't reclose files already closed
In case of error don't re-close files already closed. https://github.com/xemul/criu/issues/148 Reported-by: Andrew Vagin <avagin@virtuozzo.com> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org> Reviewed-by: Andrey Vagin <avagin@virtuozzo.com> Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
2ac20e7908
commit
ddcb61de13
1 changed files with 12 additions and 6 deletions
|
|
@ -73,12 +73,12 @@ static int piegen(void)
|
|||
{
|
||||
struct stat st;
|
||||
void *mem;
|
||||
int fd;
|
||||
int fd, ret = -1;
|
||||
|
||||
fd = open(opts.input_filename, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
pr_perror("Can't open file %s", opts.input_filename);
|
||||
goto err;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fstat(fd, &st)) {
|
||||
|
|
@ -99,15 +99,21 @@ static int piegen(void)
|
|||
}
|
||||
|
||||
if (handle_elf(mem, st.st_size)) {
|
||||
fclose(fout);
|
||||
close(fd), fd = -1;
|
||||
unlink(opts.output_filename);
|
||||
goto err;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
err:
|
||||
fclose(fout);
|
||||
printf("%s generated successfully.\n", opts.output_filename);
|
||||
return 0;
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
if (fout)
|
||||
fclose(fout);
|
||||
if (!ret)
|
||||
printf("%s generated successfully.\n", opts.output_filename);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue