mirror of
https://github.com/mpv-player/mpv.git
synced 2025-12-28 05:33:14 +00:00
command: avoid division by zero in av_timecode_make_string()
`av_timecode_make_string()` divides by fps unconditionally. And relying on container_fps always carrying a meaningful value was misguided. So we now check that fps is non-zero before calling that function. Issue encountered with a couple of old FLV files triggering a segfault. Signed-off-by: Mohammad AlSaleh <CE.Mohammad.AlSaleh@gmail.com>
This commit is contained in:
committed by
Kacper Michajłow
parent
2ac1d6db32
commit
28a4e19a67
@@ -2541,14 +2541,19 @@ static int mp_property_video_frame_info(void *ctx, struct m_property *prop,
|
|||||||
|
|
||||||
char approx_smpte[AV_TIMECODE_STR_SIZE] = {0};
|
char approx_smpte[AV_TIMECODE_STR_SIZE] = {0};
|
||||||
if (s12m_tc[0] == '\0' && mpctx->vo_chain) {
|
if (s12m_tc[0] == '\0' && mpctx->vo_chain) {
|
||||||
const AVTimecode tcr = {
|
unsigned container_fps = lrint(mpctx->vo_chain->filter->container_fps);
|
||||||
.start = 0,
|
// Avoid division-by-zero in av_timecode_make_string() if reported
|
||||||
.flags = AV_TIMECODE_FLAG_DROPFRAME,
|
// container_fps is or rounds to 0.
|
||||||
.rate = av_d2q(mpctx->vo_chain->filter->container_fps, INT_MAX),
|
if (container_fps) {
|
||||||
.fps = lrint(mpctx->vo_chain->filter->container_fps),
|
const AVTimecode tcr = {
|
||||||
};
|
.start = 0,
|
||||||
int frame = lrint(get_current_pos_ratio(mpctx, false) * get_frame_count(mpctx));
|
.flags = AV_TIMECODE_FLAG_DROPFRAME,
|
||||||
av_timecode_make_string(&tcr, approx_smpte, frame);
|
.rate = av_d2q(mpctx->vo_chain->filter->container_fps, INT_MAX),
|
||||||
|
.fps = container_fps,
|
||||||
|
};
|
||||||
|
int frame = lrint(get_current_pos_ratio(mpctx, false) * get_frame_count(mpctx));
|
||||||
|
av_timecode_make_string(&tcr, approx_smpte, frame);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct m_sub_property props[] = {
|
struct m_sub_property props[] = {
|
||||||
|
|||||||
Reference in New Issue
Block a user