From 50401f5fb7d778583b03a13bc4440f71063d319d Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Sun, 27 Dec 2015 20:00:10 +0100 Subject: [PATCH] avcodec: properly check pkt_timebase for validity Unset/invalid timebases have a zero numerator. This makes the checks consistent with other timebase checks and fixes an integer division by 0. --- libavcodec/libzvbi-teletextdec.c | 2 +- libavcodec/utils.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/libzvbi-teletextdec.c b/libavcodec/libzvbi-teletextdec.c index ff968ad29c..4e59531216 100644 --- a/libavcodec/libzvbi-teletextdec.c +++ b/libavcodec/libzvbi-teletextdec.c @@ -412,7 +412,7 @@ static int teletext_decode_frame(AVCodecContext *avctx, void *data, int *data_si } } - if (avctx->pkt_timebase.den && pkt->pts != AV_NOPTS_VALUE) + if (avctx->pkt_timebase.num && pkt->pts != AV_NOPTS_VALUE) ctx->pts = av_rescale_q(pkt->pts, avctx->pkt_timebase, AV_TIME_BASE_Q); if (pkt->size) { diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 19f3f0ac12..33295ed270 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -2435,7 +2435,7 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, } else { avctx->internal->pkt = &pkt_recoded; - if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE) + if (avctx->pkt_timebase.num && avpkt->pts != AV_NOPTS_VALUE) sub->pts = av_rescale_q(avpkt->pts, avctx->pkt_timebase, AV_TIME_BASE_Q); ret = avctx->codec->decode(avctx, sub, got_sub_ptr, &pkt_recoded);