Skip to content

Commit

Permalink
Merge pull request #629 from Enet4/bug/core/panic-on-empty-fragments
Browse files Browse the repository at this point in the history
[core] Prevent panic on From<Vec<Fragments>> for PixelFragmentSequence with an empty vector
  • Loading branch information
Enet4 authored Jan 16, 2025
2 parents c0a486d + fe37e90 commit edab427
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 edab427

Please sign in to comment.