changeset 2418:699b5e756bc4

fix for #135: do not read from already freed memory. patch by Jussi Judin. thanks Jussi!
author Yoshiki Yazawa <yaz@cc.rim.or.jp>
date Fri, 22 Feb 2008 17:38:24 +0900
parents 0427c5d07a66
children 944a510f5200
files src/demac/plugin.c
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/demac/plugin.c	Fri Feb 22 17:25:46 2008 +0900
+++ b/src/demac/plugin.c	Fri Feb 22 17:38:24 2008 +0900
@@ -326,11 +326,6 @@
     aud_vfs_rewind(vfd);
     ape_read_header(ctx, vfd, 1);
     aud_tuple_associate_int(tpl, FIELD_LENGTH, NULL, ctx->duration);
-    ape_read_close(ctx);
-    free(ctx);
-
-    if (tag) mowgli_dictionary_destroy(tag, destroy_cb, NULL);
-    
     g_sprintf(codec_string, "Monkey's Audio v%4.2f", (float)ctx->fileversion/1000.0);
 #ifdef DEBUG
     fprintf(stderr, "** demac: plugin.c: Codec: %s\n", codec_string);
@@ -338,6 +333,12 @@
     aud_tuple_associate_string(tpl, FIELD_CODEC, NULL, codec_string);
     aud_tuple_associate_string(tpl, FIELD_QUALITY, NULL, "lossless");
     aud_tuple_associate_string(tpl, FIELD_MIMETYPE, NULL, "audio/x-ape");
+
+    ape_read_close(ctx);
+    free(ctx);
+
+    if (tag) mowgli_dictionary_destroy(tag, destroy_cb, NULL);
+
     return tpl;
 }