From ef3da8f4d801c03b7cd4832856d9129dde4c7ff3 Mon Sep 17 00:00:00 2001 From: lieff Date: Wed, 12 May 2021 14:54:19 +0300 Subject: [PATCH] test: check operations with with zero initialized mp3dec_ex decoder --- minimp3_test.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/minimp3_test.c b/minimp3_test.c index 329f973..4f8a491 100644 --- a/minimp3_test.c +++ b/minimp3_test.c @@ -506,6 +506,13 @@ static int self_test(const char *input_file_name) ret = mp3dec_iterate_cb(&io, buf, 0, frames_iterate_cb, 0); ASSERT(MP3D_E_PARAM == ret); + memset(&dec, 0, sizeof(dec)); + ret = mp3dec_ex_seek(&dec, 10); /* seek with zero initialized decoder - no-op without fail */ + ASSERT(0 == ret); + ret = mp3dec_ex_read(&dec, (mp3d_sample_t*)buf, 10); /* read with zero initialized decoder - reads zero samples */ + ASSERT(0 == ret); + mp3dec_ex_close(&dec); /* close zero initialized decoder - should not crash */ + ret = mp3dec_ex_open_buf(0, buf, size, MP3D_SEEK_TO_SAMPLE); ASSERT(MP3D_E_PARAM == ret); ret = mp3dec_ex_open_buf(&dec, 0, size, MP3D_SEEK_TO_SAMPLE);