mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-23 02:26:35 +00:00
uriplaylistbin: prevent overflow panic with infinite playlist
enumerate() will panic if the index overflows.
This commit is contained in:
parent
4a5815cc97
commit
9783d01a35
1 changed files with 9 additions and 1 deletions
|
@ -613,12 +613,15 @@ struct ItemInner {
|
|||
|
||||
struct Playlist {
|
||||
items: Box<dyn Iterator<Item = Item> + Send>,
|
||||
|
||||
uris: Vec<String>,
|
||||
}
|
||||
|
||||
impl Playlist {
|
||||
fn new(uris: Vec<String>, 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))
|
||||
|
|
Loading…
Reference in a new issue