aboutsummaryrefslogtreecommitdiff
path: root/osdep.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-08-17 16:19:07 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-08-17 16:19:07 +0000
commit243a273ee0168fc373f342479ae92fe3028b45c1 (patch)
tree3849db26dff1507c7926c27d92187e4a45932985 /osdep.c
parentc3d78997a3235b2bb500c9eae4f0389550d77a35 (diff)
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.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/osdep.c b/osdep.c
index 348fcf2cae..1a4c03688e 100644
--- a/osdep.c
+++ b/osdep.c
@@ -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;