From: Dunrong Huang Date: Wed, 5 Sep 2012 13:26:22 +0000 (+0800) Subject: block: Don't forget to delete temporary file X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=fe235a06e1e008dedd2ac3cc0a3a655169ce9b33;p=qmiga%2Fqemu.git 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 Signed-off-by: Kevin Wolf --- diff --git a/block.c b/block.c index c754353ac6..e78039bd5a 100644 --- a/block.c +++ b/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;