From 158fe231811c66c7a0ec3457bc428dc839039491 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Fri, 19 Jan 2018 20:40:00 -0800 Subject: [PATCH] Don't crash on an invalid (layer I or II) frame We removed the MP2-layer I and II decoders to save space, but an occasional bad frame can come in that, by random chance, specifies one of this type. Was calling NULL because of that. Now, just skip the frame and no crash. --- src/libmad/frame.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libmad/frame.c b/src/libmad/frame.c index 831783b..92e7e8e 100644 --- a/src/libmad/frame.c +++ b/src/libmad/frame.c @@ -451,6 +451,11 @@ int mad_frame_decode(struct mad_frame *frame, struct mad_stream *stream) frame->header.flags &= ~MAD_FLAG_INCOMPLETE; + // EFP3 - On non-MP3 frames, abort instead of crash..we removed MP-II/MP-I decoders + if (!decoder_table[frame->header.layer - 1]) { + goto fail; + } + if (decoder_table[frame->header.layer - 1](stream, frame) == -1) { if (!MAD_RECOVERABLE(stream->error)) stream->next_frame = stream->this_frame;