mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-01 14:53:54 -06:00
block: Don't forget to delete temporary file
The caller would not delete temporary file after failed get_tmp_filename(). Signed-off-by: Dunrong Huang <riegamaths@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
f0536bb848
commit
fe235a06e1
1 changed files with 5 additions and 1 deletions
6
block.c
6
block.c
|
@ -433,7 +433,11 @@ int get_tmp_filename(char *filename, int size)
|
|||
return -EOVERFLOW;
|
||||
}
|
||||
fd = mkstemp(filename);
|
||||
if (fd < 0 || close(fd)) {
|
||||
if (fd < 0) {
|
||||
return -errno;
|
||||
}
|
||||
if (close(fd) != 0) {
|
||||
unlink(filename);
|
||||
return -errno;
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue