Commit e84a4fedf74983ad0517b4754f927a96a2eea7ce
1 parent
fb43f4dd
mem leak fixes
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2102 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
14 additions
and
15 deletions
audio/wavcapture.c
@@ -34,22 +34,19 @@ static void wav_destroy (void *opaque) | @@ -34,22 +34,19 @@ static void wav_destroy (void *opaque) | ||
34 | uint32_t datalen = wav->bytes; | 34 | uint32_t datalen = wav->bytes; |
35 | uint32_t rifflen = datalen + 36; | 35 | uint32_t rifflen = datalen + 36; |
36 | 36 | ||
37 | - if (!wav->f) { | ||
38 | - return; | ||
39 | - } | ||
40 | - | ||
41 | - le_store (rlen, rifflen, 4); | ||
42 | - le_store (dlen, datalen, 4); | ||
43 | - | ||
44 | - qemu_fseek (wav->f, 4, SEEK_SET); | ||
45 | - qemu_put_buffer (wav->f, rlen, 4); | ||
46 | - | ||
47 | - qemu_fseek (wav->f, 32, SEEK_CUR); | ||
48 | - qemu_put_buffer (wav->f, dlen, 4); | ||
49 | - qemu_fclose (wav->f); | ||
50 | - if (wav->path) { | ||
51 | - qemu_free (wav->path); | 37 | + if (wav->f) { |
38 | + le_store (rlen, rifflen, 4); | ||
39 | + le_store (dlen, datalen, 4); | ||
40 | + | ||
41 | + qemu_fseek (wav->f, 4, SEEK_SET); | ||
42 | + qemu_put_buffer (wav->f, rlen, 4); | ||
43 | + | ||
44 | + qemu_fseek (wav->f, 32, SEEK_CUR); | ||
45 | + qemu_put_buffer (wav->f, dlen, 4); | ||
46 | + qemu_fclose (wav->f); | ||
52 | } | 47 | } |
48 | + | ||
49 | + qemu_free (wav->path); | ||
53 | } | 50 | } |
54 | 51 | ||
55 | static void wav_capture (void *opaque, void *buf, int size) | 52 | 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, | @@ -153,6 +150,8 @@ int wav_start_capture (CaptureState *s, const char *path, int freq, | ||
153 | cap = AUD_add_capture (NULL, &as, &ops, wav); | 150 | cap = AUD_add_capture (NULL, &as, &ops, wav); |
154 | if (!cap) { | 151 | if (!cap) { |
155 | term_printf ("Failed to add audio capture\n"); | 152 | term_printf ("Failed to add audio capture\n"); |
153 | + qemu_free (wav->path); | ||
154 | + qemu_fclose (wav->f); | ||
156 | qemu_free (wav); | 155 | qemu_free (wav); |
157 | return -1; | 156 | return -1; |
158 | } | 157 | } |