Avoid crash in samplebuilder.PopWithTimestamp

If sample is null, PopWithTimestamp will crash with SIGSEGV.
This commit is contained in:
Juliusz Chroboczek
2021-06-20 19:52:21 +02:00
committed by Sean DuBois
parent 41243cd179
commit 11f6a65fe2
2 changed files with 12 additions and 0 deletions

View File

@@ -379,3 +379,12 @@ func TestSampleBuilderWithPacketReleaseHandler(t *testing.T) {
t.Errorf("Unexpected packet released by samples built")
}
}
func TestPopWithTimestamp(t *testing.T) {
t.Run("Crash on nil", func(t *testing.T) {
s := New(0, &fakeDepacketizer{}, 1)
sample, timestamp := s.PopWithTimestamp()
assert.Nil(t, sample)
assert.Equal(t, uint32(0), timestamp)
})
}