avcodec/flac_parser: ensure there are more headers for scoring

Previously invalid frame may be returned, happened when seeking.

Fixes #7684
pull/388/head
Paul B Mahol 2 years ago
parent e4c1272711
commit 5ca781598e
  1. 4
      libavcodec/flac_parser.c

@ -600,7 +600,7 @@ static int score_header(FLACParseContext *fpc, FLACHeaderMarker *header)
static void score_sequences(FLACParseContext *fpc)
{
FLACHeaderMarker *curr;
int best_score = 0;//FLAC_HEADER_NOT_SCORED_YET;
int best_score = FLAC_HEADER_NOT_SCORED_YET;
/* First pass to clear all old scores. */
for (curr = fpc->headers; curr; curr = curr->next)
curr->max_score = FLAC_HEADER_NOT_SCORED_YET;
@ -682,7 +682,7 @@ static int flac_parse(AVCodecParserContext *s, AVCodecContext *avctx,
}
fpc->avctx = avctx;
if (fpc->best_header_valid)
if (fpc->best_header_valid && fpc->nb_headers_buffered >= FLAC_MIN_HEADERS)
return get_best_header(fpc, poutbuf, poutbuf_size);
/* If a best_header was found last call remove it with the buffer data. */

Loading…
Cancel
Save