comparison src/demac/plugin.c @ 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 05c9bec29aaa
children ed6c81bd9016
comparison
equal deleted inserted replaced
2417:0427c5d07a66 2418:699b5e756bc4
324 324
325 APEContext *ctx = calloc(sizeof(APEContext), 1); 325 APEContext *ctx = calloc(sizeof(APEContext), 1);
326 aud_vfs_rewind(vfd); 326 aud_vfs_rewind(vfd);
327 ape_read_header(ctx, vfd, 1); 327 ape_read_header(ctx, vfd, 1);
328 aud_tuple_associate_int(tpl, FIELD_LENGTH, NULL, ctx->duration); 328 aud_tuple_associate_int(tpl, FIELD_LENGTH, NULL, ctx->duration);
329 ape_read_close(ctx);
330 free(ctx);
331
332 if (tag) mowgli_dictionary_destroy(tag, destroy_cb, NULL);
333
334 g_sprintf(codec_string, "Monkey's Audio v%4.2f", (float)ctx->fileversion/1000.0); 329 g_sprintf(codec_string, "Monkey's Audio v%4.2f", (float)ctx->fileversion/1000.0);
335 #ifdef DEBUG 330 #ifdef DEBUG
336 fprintf(stderr, "** demac: plugin.c: Codec: %s\n", codec_string); 331 fprintf(stderr, "** demac: plugin.c: Codec: %s\n", codec_string);
337 #endif 332 #endif
338 aud_tuple_associate_string(tpl, FIELD_CODEC, NULL, codec_string); 333 aud_tuple_associate_string(tpl, FIELD_CODEC, NULL, codec_string);
339 aud_tuple_associate_string(tpl, FIELD_QUALITY, NULL, "lossless"); 334 aud_tuple_associate_string(tpl, FIELD_QUALITY, NULL, "lossless");
340 aud_tuple_associate_string(tpl, FIELD_MIMETYPE, NULL, "audio/x-ape"); 335 aud_tuple_associate_string(tpl, FIELD_MIMETYPE, NULL, "audio/x-ape");
336
337 ape_read_close(ctx);
338 free(ctx);
339
340 if (tag) mowgli_dictionary_destroy(tag, destroy_cb, NULL);
341
341 return tpl; 342 return tpl;
342 } 343 }
343 344
344 Tuple *demac_get_tuple(char *filename) { 345 Tuple *demac_get_tuple(char *filename) {
345 #ifdef DEBUG 346 #ifdef DEBUG