diff options
author | Max Kellermann <max@duempel.org> | 2009-11-11 19:05:24 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-11-11 19:05:24 +0100 |
commit | 4a8cc87b4d6e57f2149bd60f48f9a1b69c454593 (patch) | |
tree | 8a6e0189cfd94ee43dc40724abd0cf5cf1013e60 /src/decoder/flac_plugin.c | |
parent | 183725733a929e433c584d5c02016e0d299ced7a (diff) | |
download | mpd-4a8cc87b4d6e57f2149bd60f48f9a1b69c454593.tar.gz mpd-4a8cc87b4d6e57f2149bd60f48f9a1b69c454593.tar.xz mpd-4a8cc87b4d6e57f2149bd60f48f9a1b69c454593.zip |
decoder/flac: free the "pathname" variable earlier
Free the pointer right after its last use, i.e. after the
FLAC__stream_decoder_init_file() call.
Diffstat (limited to 'src/decoder/flac_plugin.c')
-rw-r--r-- | src/decoder/flac_plugin.c | 46 |
1 files changed, 15 insertions, 31 deletions
diff --git a/src/decoder/flac_plugin.c b/src/decoder/flac_plugin.c index 0a47b5d7f..c7be1b81b 100644 --- a/src/decoder/flac_plugin.c +++ b/src/decoder/flac_plugin.c @@ -531,6 +531,7 @@ flac_container_decode(struct decoder* decoder, FLAC__StreamMetadata* cs = NULL; FLAC__StreamDecoder *flac_dec; + FLAC__StreamDecoderInitStatus init_status; struct flac_data data; const char *err = NULL; @@ -578,34 +579,20 @@ flac_container_decode(struct decoder* decoder, } #endif - - if (is_ogg) - { - if (FLAC__stream_decoder_init_ogg_file( flac_dec, - pathname, - flac_write_cb, - flacMetadata, - flac_error_cb, - (void*) &data ) - != FLAC__STREAM_DECODER_INIT_STATUS_OK ) - { - err = "doing Ogg init()"; - goto fail; - } - } - else - { - if (FLAC__stream_decoder_init_file( flac_dec, - pathname, - flac_write_cb, - flacMetadata, - flac_error_cb, - (void*) &data ) - != FLAC__STREAM_DECODER_INIT_STATUS_OK ) - { - err = "doing init()"; - goto fail; - } + init_status = is_ogg + ? FLAC__stream_decoder_init_ogg_file(flac_dec, pathname, + flac_write_cb, + flacMetadata, + flac_error_cb, + &data) + : FLAC__stream_decoder_init_file(flac_dec, + pathname, flac_write_cb, + flacMetadata, flac_error_cb, + &data); + g_free(pathname); + if (init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) { + err = "doing init()"; + goto fail; } if (!FLAC__stream_decoder_process_until_end_of_metadata(flac_dec)) @@ -637,9 +624,6 @@ flac_container_decode(struct decoder* decoder, flac_decoder_loop(&data, flac_dec, t_start, t_end); fail: - if (pathname) - g_free(pathname); - flac_data_deinit(&data); FLAC__stream_decoder_delete(flac_dec); |