From 2416ea6856cb36d064a079cc5e9674383c8b2eae Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Fri, 23 Mar 2007 18:42:45 +0100 Subject: [PATCH] mp3_afh.c: Fix header_bitrate() for invalid headers This was broken literally since day 1: If the layer or the bitrate parameter of an (invalid) header is zero, the old code might cause a segfault. --- mp3_afh.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mp3_afh.c b/mp3_afh.c index cf507ec2..0c8efbdc 100644 --- a/mp3_afh.c +++ b/mp3_afh.c @@ -115,9 +115,10 @@ static const char *header_mode(struct mp3header *h) h->mode = 4; /* invalid */ return mode_text[h->mode]; } + static int header_bitrate(struct mp3header *h) { - if (h->layer > 3 || h->bitrate > 14) + if (!h->layer || h->layer > 3 || h->bitrate > 14 || !h->bitrate) return -E_HEADER_BITRATE; return mp3info_bitrate[h->version & 1][3 - h->layer][h->bitrate - 1]; } -- 2.39.5