From 9783d01a3520ad23dca7f1f2a76693d2755c292b Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Wed, 22 Dec 2021 12:52:07 +0100 Subject: [PATCH] uriplaylistbin: prevent overflow panic with infinite playlist enumerate() will panic if the index overflows. --- utils/uriplaylistbin/src/uriplaylistbin/imp.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs index 979be020..d44f9cea 100644 --- a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs +++ b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs @@ -613,12 +613,15 @@ struct ItemInner { struct Playlist { items: Box + Send>, + + uris: Vec, } impl Playlist { fn new(uris: Vec, iterations: u32) -> Self { Self { - items: Self::create_items(uris, iterations), + items: Self::create_items(uris.clone(), iterations), + uris, } } @@ -664,6 +667,11 @@ impl Playlist { Some(item) => item, }; + if item.index() == usize::MAX { + // prevent overflow with infinite playlist + self.items = Self::create_items(self.uris.clone(), 0); + } + item.set_waiting_for_stream_collection()?; Ok(Some(item))