From f871d24c5441c666878f61b6426f44b3f0a09a6d Mon Sep 17 00:00:00 2001 From: Polochon-street Date: Mon, 14 Jun 2021 21:02:30 +0200 Subject: [PATCH] Fix potential segfault in Song::decode --- src/song.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/song.rs b/src/song.rs index 4442981..f7587f3 100644 --- a/src/song.rs +++ b/src/song.rs @@ -510,6 +510,7 @@ fn resample_frame( ) -> Result, BlissError> { let mut resampled = ffmpeg::frame::Audio::empty(); for decoded in rx.iter() { + resampled = ffmpeg::frame::Audio::empty(); resample_context .run(&decoded, &mut resampled) .map_err(|e| { @@ -517,6 +518,8 @@ fn resample_frame( })?; push_to_sample_array(&resampled, &mut sample_array); } + // TODO when ffmpeg-next will be active again: shouldn't we allocate + // `resampled` again? loop { match resample_context.flush(&mut resampled).map_err(|e| { BlissError::DecodingError(format!("while trying to resample song: {:?}", e))