Skip to content

Commit

Permalink
Merge pull request #32 from sevonj/fix-empty-pgen
Browse files Browse the repository at this point in the history
Fix: crash on empty pgen chunk
  • Loading branch information
sinshu authored Jan 11, 2025
2 parents 0d174d8 + 10a74a4 commit 2746a5f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rustysynth/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Generator {
reader: &mut R,
size: usize,
) -> Result<Vec<Generator>, SoundFontError> {
if size % 4 != 0 {
if size == 0 || size % 4 != 0 {
return Err(SoundFontError::InvalidGeneratorList);
}

Expand Down
2 changes: 1 addition & 1 deletion rustysynth/src/sample_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl SampleHeader {
reader: &mut R,
size: usize,
) -> Result<Vec<SampleHeader>, SoundFontError> {
if size % 46 != 0 {
if size == 0 || size % 46 != 0 {
return Err(SoundFontError::InvalidSampleHeaderList);
}

Expand Down
2 changes: 1 addition & 1 deletion rustysynth/src/zone_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl ZoneInfo {
reader: &mut R,
size: usize,
) -> Result<Vec<ZoneInfo>, SoundFontError> {
if size % 4 != 0 {
if size == 0 || size % 4 != 0 {
return Err(SoundFontError::InvalidZoneList);
}

Expand Down

0 comments on commit 2746a5f

Please sign in to comment.