aboutsummaryrefslogtreecommitdiff
path: root/audio/wavcapture.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-08-07 21:35:12 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2006-08-07 21:35:12 +0000
commite84a4fedf74983ad0517b4754f927a96a2eea7ce (patch)
treeeac09c5c33daa34c45ebbace31934aad44fe009c /audio/wavcapture.c
parentfb43f4dddc1512e6429c526871b48c99292a4861 (diff)
downloadqemu-e84a4fedf74983ad0517b4754f927a96a2eea7ce.zip
qemu-e84a4fedf74983ad0517b4754f927a96a2eea7ce.tar.gz
qemu-e84a4fedf74983ad0517b4754f927a96a2eea7ce.tar.bz2
mem leak fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2102 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'audio/wavcapture.c')
-rw-r--r--audio/wavcapture.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/audio/wavcapture.c b/audio/wavcapture.c
index d1a6f7b..d915fa0 100644
--- a/audio/wavcapture.c
+++ b/audio/wavcapture.c
@@ -34,22 +34,19 @@ static void wav_destroy (void *opaque)
uint32_t datalen = wav->bytes;
uint32_t rifflen = datalen + 36;
- if (!wav->f) {
- return;
- }
-
- le_store (rlen, rifflen, 4);
- le_store (dlen, datalen, 4);
-
- qemu_fseek (wav->f, 4, SEEK_SET);
- qemu_put_buffer (wav->f, rlen, 4);
-
- qemu_fseek (wav->f, 32, SEEK_CUR);
- qemu_put_buffer (wav->f, dlen, 4);
- qemu_fclose (wav->f);
- if (wav->path) {
- qemu_free (wav->path);
+ if (wav->f) {
+ le_store (rlen, rifflen, 4);
+ le_store (dlen, datalen, 4);
+
+ qemu_fseek (wav->f, 4, SEEK_SET);
+ qemu_put_buffer (wav->f, rlen, 4);
+
+ qemu_fseek (wav->f, 32, SEEK_CUR);
+ qemu_put_buffer (wav->f, dlen, 4);
+ qemu_fclose (wav->f);
}
+
+ qemu_free (wav->path);
}
static void wav_capture (void *opaque, void *buf, int size)
@@ -153,6 +150,8 @@ int wav_start_capture (CaptureState *s, const char *path, int freq,
cap = AUD_add_capture (NULL, &as, &ops, wav);
if (!cap) {
term_printf ("Failed to add audio capture\n");
+ qemu_free (wav->path);
+ qemu_fclose (wav->f);
qemu_free (wav);
return -1;
}