summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-08-07 22:48:11 +0200
committerMax Kellermann <max@musicpd.org>2018-08-07 22:48:11 +0200
commitcacc1ffdad44ded19edcca77c3308e76642033f3 (patch)
treebd82554f129115a2e1f6f4a500fda647f582cac1
parentcfe34647e1ea0898ad4ab23d4518e9fabf00c6d9 (diff)
decoder/mpg123: use AtScopeExit() to call mpg123_delete() during scan
-rw-r--r--src/decoder/plugins/Mpg123DecoderPlugin.cxx7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/decoder/plugins/Mpg123DecoderPlugin.cxx b/src/decoder/plugins/Mpg123DecoderPlugin.cxx
index de002f29a..7b7af4a6f 100644
--- a/src/decoder/plugins/Mpg123DecoderPlugin.cxx
+++ b/src/decoder/plugins/Mpg123DecoderPlugin.cxx
@@ -287,20 +287,19 @@ mpd_mpg123_scan_file(Path path_fs, TagHandler &handler) noexcept
return false;
}
+ AtScopeExit(handle) { mpg123_delete(handle); };
+
AudioFormat audio_format;
try {
if (!mpd_mpg123_open(handle, path_fs.c_str(), audio_format)) {
- mpg123_delete(handle);
return false;
}
} catch (...) {
- mpg123_delete(handle);
return false;
}
const off_t num_samples = mpg123_length(handle);
if (num_samples <= 0) {
- mpg123_delete(handle);
return false;
}
@@ -308,8 +307,6 @@ mpd_mpg123_scan_file(Path path_fs, TagHandler &handler) noexcept
/* ID3 tag support not yet implemented */
- mpg123_delete(handle);
-
const auto duration =
SongTime::FromScale<uint64_t>(num_samples,
audio_format.sample_rate);