Merge pull request #15 from Polochon-street/fix-segfault

Fix potential segfault in Song::decode
This commit is contained in:
Polochon-street 2021-06-14 23:11:21 +02:00
commit 78651c17c7
4 changed files with 8 additions and 2 deletions

View file

@ -1,5 +1,8 @@
# Changelog
## bliss 0.2.6
* Fixed an allocation bug in Song::decode that potentially caused segfaults.
## bliss 0.2.5
* Updates to docs

2
Cargo.lock generated
View file

@ -75,7 +75,7 @@ checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "bliss-audio"
version = "0.2.5"
version = "0.2.6"
dependencies = [
"bliss-audio-aubio-rs",
"crossbeam",

View file

@ -1,6 +1,6 @@
[package]
name = "bliss-audio"
version = "0.2.5"
version = "0.2.6"
authors = ["Polochon-street <polochonstreet@gmx.fr>"]
edition = "2018"
license = "GPL-3.0-only"

View file

@ -510,6 +510,7 @@ fn resample_frame(
) -> Result<Vec<f32>, 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))