diff options
author | Max Kellermann <max@duempel.org> | 2009-01-04 15:01:28 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-04 15:01:28 +0100 |
commit | 16c224a7fa542eba121203512ef7f2b953f8e7f1 (patch) | |
tree | 907036d41928a02bcbf02127f37595c491d6304e | |
parent | fc39d1d3eaa8640fd429fb04110290814718819e (diff) | |
download | mpd-16c224a7fa542eba121203512ef7f2b953f8e7f1.tar.gz mpd-16c224a7fa542eba121203512ef7f2b953f8e7f1.tar.xz mpd-16c224a7fa542eba121203512ef7f2b953f8e7f1.zip |
decoder_api: moved code to do_send_tag(), free temporary tag
This patch fixes a minor memory leak: when decoder_tag() attempted to
send a merged tag object (created by tag_add_stream_tags()), and was
interrupted by a decoder command, it did not free the temporary merged
tag object.
Diffstat (limited to '')
-rw-r--r-- | NEWS | 1 | ||||
-rw-r--r-- | src/decoder_api.c | 24 |
2 files changed, 18 insertions, 7 deletions
@@ -7,6 +7,7 @@ MPD 0.14.1 - not yet released * log: automatically append newline * fix setenv() conflict on Solaris * configure.ac: check for pkg-config before using it +* fix minor memory leak in decoder_tag() ver 0.14 (2008/12/25) diff --git a/src/decoder_api.c b/src/decoder_api.c index dd7096017..8a7e2a4da 100644 --- a/src/decoder_api.c +++ b/src/decoder_api.c @@ -181,6 +181,18 @@ need_chunks(struct input_stream *is, bool wait) return DECODE_COMMAND_NONE; } +static enum decoder_command +do_send_tag(struct input_stream *is, const struct tag *tag) +{ + while (!music_pipe_tag(tag)) { + enum decoder_command cmd = need_chunks(is, true); + if (cmd != DECODE_COMMAND_NONE) + return cmd; + } + + return DECODE_COMMAND_NONE; +} + enum decoder_command decoder_data(struct decoder *decoder, struct input_stream *is, @@ -287,22 +299,20 @@ decoder_tag(G_GNUC_UNUSED struct decoder *decoder, struct input_stream *is, const struct tag *tag) { struct tag *tag2 = is != NULL ? tag_add_stream_tags(tag, is) : NULL; + enum decoder_command cmd; assert(dc.state == DECODE_STATE_DECODE); if (tag2 != NULL) tag = tag2; - while (!music_pipe_tag(tag)) { - enum decoder_command cmd = need_chunks(is, true); - if (cmd != DECODE_COMMAND_NONE) - return cmd; - } + cmd = do_send_tag(is, tag); if (tag2 != NULL) tag_free(tag2); - decoder->stream_tag_sent = true; + if (cmd == DECODE_COMMAND_NONE) + decoder->stream_tag_sent = true; - return DECODE_COMMAND_NONE; + return cmd; } |