Skip to content

Commit 564ac6f

Browse files
committed
Fix exception for ogg packets with only one block flag
1 parent e55e8c1 commit 564ac6f

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

Fmod5Sharp.Tests/Fmod5Sharp.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
<EmbeddedResource Include="TestResources\previously_unrecoverable_vorbis.fsb" />
5151
<None Remove="TestResources\xbox_imaad.fsb" />
5252
<EmbeddedResource Include="TestResources\xbox_imaad.fsb" />
53+
<None Remove="TestResources\vorbis_with_blockflag_exception.fsb" />
54+
<EmbeddedResource Include="TestResources\vorbis_with_blockflag_exception.fsb" />
5355
</ItemGroup>
5456

5557
</Project>

Fmod5Sharp.Tests/Fmod5SharpVorbisTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,19 @@ public void PreviouslyUnrecoverableVorbisFilesWorkWithOurCustomRebuilder()
5959

6060
Assert.NotEmpty(oggBytes);
6161
}
62+
63+
[Fact]
64+
public void VorbisFilesThatPreviouslyThrewExceptionsDoNot()
65+
{
66+
var rawData = this.LoadResource("vorbis_with_blockflag_exception.fsb");
67+
68+
var samples = FsbLoader.LoadFsbFromByteArray(rawData).Samples;
69+
70+
var sample = samples[0];
71+
72+
var oggBytes = FmodVorbisRebuilder.RebuildOggFile(sample);
73+
74+
Assert.NotEmpty(oggBytes);
75+
}
6276
}
6377
}
Binary file not shown.

Fmod5Sharp/Util/FmodVorbisData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public int GetPacketBlockSize(byte[] packetBytes)
6868

6969
var mode = 0;
7070

71-
if (BlockFlags.Length > 0)
71+
if (BlockFlags.Length > 1)
7272
mode = bitStream.ReadByte(BlockFlags.Length - 1);
7373

7474
if (BlockFlags[mode] == 1)

0 commit comments

Comments
 (0)