Skip to content

Commit 8c841af

Browse files
committed
MP3File: Avoid crash in get_buffer when deinitted
When a playing mp3 is deinitted, it's possible to reach get_buffer, but all the internal pointers are NULL. This would lead to a hard fault. Avoid it by returning GET_BUFFER_ERROR instead.
1 parent 024ba97 commit 8c841af

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

shared-module/audiomp3/MP3File.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t*
227227
uint8_t channel,
228228
uint8_t** bufptr,
229229
uint32_t* buffer_length) {
230+
if (!self->inbuf) {
231+
return GET_BUFFER_ERROR;
232+
}
230233
if (!single_channel) {
231234
channel = 0;
232235
}

0 commit comments

Comments
 (0)