X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fffmetadec.c;h=93ec6f589953ef90cb7f4f43439c77e5cefa7b27;hb=bc70684e74a185d7b80c8b80bdedda659cb581b8;hp=6f7133e3895258fa56e2c4604ecea49ff695561b;hpb=b8eb0827f053230dd919bc73e25381b47b4fe1a7;p=ffmpeg diff --git a/libavformat/ffmetadec.c b/libavformat/ffmetadec.c index 6f7133e3895..93ec6f58995 100644 --- a/libavformat/ffmetadec.c +++ b/libavformat/ffmetadec.c @@ -26,7 +26,7 @@ #include "internal.h" #include "libavutil/dict.h" -static int probe(AVProbeData *p) +static int probe(const AVProbeData *p) { if(!memcmp(p->buf, ID_STRING, strlen(ID_STRING))) return AVPROBE_SCORE_MAX; @@ -101,19 +101,22 @@ static AVChapter *read_chapter(AVFormatContext *s) uint8_t line[256]; int64_t start, end; AVRational tb = {1, 1e9}; + int ret; get_line(s->pb, line, sizeof(line)); if (sscanf(line, "TIMEBASE=%d/%d", &tb.num, &tb.den)) get_line(s->pb, line, sizeof(line)); - if (!sscanf(line, "START=%"SCNd64, &start)) { + ret = sscanf(line, "START=%"SCNd64, &start); + if (ret <= 0) { av_log(s, AV_LOG_ERROR, "Expected chapter start timestamp, found %s.\n", line); start = (s->nb_chapters && s->chapters[s->nb_chapters - 1]->end != AV_NOPTS_VALUE) ? s->chapters[s->nb_chapters - 1]->end : 0; } else get_line(s->pb, line, sizeof(line)); - if (!sscanf(line, "END=%"SCNd64, &end)) { + ret = sscanf(line, "END=%"SCNd64, &end); + if (ret <= 0) { av_log(s, AV_LOG_ERROR, "Expected chapter end timestamp, found %s.\n", line); end = AV_NOPTS_VALUE; } @@ -182,7 +185,7 @@ static int read_header(AVFormatContext *s) AVStream *st = avformat_new_stream(s, NULL); if (!st) - return AVERROR(ENOMEM); + goto nomem; st->codecpar->codec_type = AVMEDIA_TYPE_DATA; st->codecpar->codec_id = AV_CODEC_ID_FFMETADATA; @@ -192,7 +195,7 @@ static int read_header(AVFormatContext *s) AVChapter *ch = read_chapter(s); if (!ch) - return AVERROR(ENOMEM); + goto nomem; m = &ch->metadata; } else @@ -208,6 +211,10 @@ static int read_header(AVFormatContext *s) AV_TIME_BASE_Q); return 0; +nomem: + av_bprint_finalize(&bp, NULL); + + return AVERROR(ENOMEM); } static int read_packet(AVFormatContext *s, AVPacket *pkt) @@ -215,7 +222,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) return AVERROR_EOF; } -AVInputFormat ff_ffmetadata_demuxer = { +const AVInputFormat ff_ffmetadata_demuxer = { .name = "ffmetadata", .long_name = NULL_IF_CONFIG_SMALL("FFmpeg metadata in text"), .read_probe = probe,