Skip to content

Commit

Permalink
[core] Prevent panic on From<Vec<Fragments>> for PixelFragmentSequenc…
Browse files Browse the repository at this point in the history
…e with an empty vector
  • Loading branch information
Enet4 committed Jan 11, 2025
1 parent 17e26a0 commit fe37e90
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions core/src/value/fragments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ impl Fragments {

impl From<Vec<Fragments>> for PixelFragmentSequence<InMemFragment> {
fn from(value: Vec<Fragments>) -> Self {
if value.is_empty() {
// return an empty fragment list
return PixelFragmentSequence {
offset_table: C::new(),
fragments: C::new(),
};
}

let mut offset_table = C::with_capacity(value.len() + 1);
offset_table.push(0u32);
let mut current_offset = 0u32;
Expand Down

0 comments on commit fe37e90

Please sign in to comment.