From f35dab1b56c8070cbe170793fdac48734ebc8caa Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 9 Dec 2016 21:46:29 +0100 Subject: [PATCH] decoder/wavpack: check WavpackGetNumSamples()==-1 --- src/decoder/plugins/WavpackDecoderPlugin.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/decoder/plugins/WavpackDecoderPlugin.cxx b/src/decoder/plugins/WavpackDecoderPlugin.cxx index b933ede40..80c75e2d4 100644 --- a/src/decoder/plugins/WavpackDecoderPlugin.cxx +++ b/src/decoder/plugins/WavpackDecoderPlugin.cxx @@ -54,6 +54,10 @@ static SignedSongTime GetDuration(WavpackContext *wpc) { const uint32_t n_samples = WavpackGetNumSamples(wpc); + if (n_samples == uint32_t(-1)) + /* unknown */ + return SignedSongTime::Negative(); + return SongTime::FromScale(n_samples, WavpackGetSampleRate(wpc)); } @@ -230,7 +234,8 @@ wavpack_scan_file(Path path_fs, }; const auto duration = GetDuration(wpc); - tag_handler_invoke_duration(handler, handler_ctx, SongTime(duration)); + if (!duration.IsNegative()) + tag_handler_invoke_duration(handler, handler_ctx, SongTime(duration)); return true; }