diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2006-08-17 16:19:07 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2006-08-17 16:19:07 +0000 |
commit | 243a273ee0168fc373f342479ae92fe3028b45c1 (patch) | |
tree | 3849db26dff1507c7926c27d92187e4a45932985 /osdep.c | |
parent | minimal PCI IDE save/restore (diff) | |
download | qemu-kvm-243a273ee0168fc373f342479ae92fe3028b45c1.tar.gz qemu-kvm-243a273ee0168fc373f342479ae92fe3028b45c1.tar.bz2 qemu-kvm-243a273ee0168fc373f342479ae92fe3028b45c1.zip |
fd leak fix (Igor Kovalenko)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2118 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'osdep.c')
-rw-r--r-- | osdep.c | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -120,7 +120,8 @@ void *kqemu_vmalloc(size_t size) } snprintf(phys_ram_file, sizeof(phys_ram_file), "%s/qemuXXXXXX", tmpdir); - if (mkstemp(phys_ram_file) < 0) { + phys_ram_fd = mkstemp(phys_ram_file); + if (phys_ram_fd < 0) { fprintf(stderr, "warning: could not create temporary file in '%s'.\n" "Use QEMU_TMPDIR to select a directory in a tmpfs filesystem.\n" @@ -128,18 +129,13 @@ void *kqemu_vmalloc(size_t size) tmpdir); snprintf(phys_ram_file, sizeof(phys_ram_file), "%s/qemuXXXXXX", "/tmp"); - if (mkstemp(phys_ram_file) < 0) { + phys_ram_fd = mkstemp(phys_ram_file); + if (phys_ram_fd < 0) { fprintf(stderr, "Could not create temporary memory file '%s'\n", phys_ram_file); exit(1); } } - phys_ram_fd = open(phys_ram_file, O_CREAT | O_TRUNC | O_RDWR, 0600); - if (phys_ram_fd < 0) { - fprintf(stderr, "Could not open temporary memory file '%s'\n", - phys_ram_file); - exit(1); - } unlink(phys_ram_file); } size = (size + 4095) & ~4095; |