From: Andre Noll Date: Fri, 23 Mar 2007 17:42:45 +0000 (+0100) Subject: mp3_afh.c: Fix header_bitrate() for invalid headers X-Git-Tag: v0.2.16~9 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=2416ea6856cb36d064a079cc5e9674383c8b2eae;p=paraslash.git 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. --- 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]; }