`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.
Unified · Split
| @@ -2541,14 +2541,19 @@ static int mp_property_video_frame_info(void *ctx, struct m_property *prop, · 2540 unmodified lines | ||
| 2541 | 2541 | |
| 2542 | 2542 | char approx_smpte[AV_TIMECODE_STR_SIZE] = {0}; |
| 2543 | 2543 | if (s12m_tc[0] == '\0' && mpctx->vo_chain) { |
| 2544 | − const AVTimecode tcr = { | |
| 2545 | − .start = 0, | |
| 2546 | − .flags = AV_TIMECODE_FLAG_DROPFRAME, | |
| 2547 | − .rate = av_d2q(mpctx->vo_chain->filter->container_fps, INT_MAX), | |
| 2548 | − .fps = lrint(mpctx->vo_chain->filter->container_fps), | |
| 2549 | − }; | |
| 2550 | − int frame = lrint(get_current_pos_ratio(mpctx, false) * get_frame_count(mpctx)); | |
| 2551 | − av_timecode_make_string(&tcr, approx_smpte, frame); | |
| 2544 | + unsigned container_fps = lrint(mpctx->vo_chain->filter->container_fps); | |
| 2545 | + // Avoid division-by-zero in av_timecode_make_string() if reported | |
| 2546 | + // container_fps is or rounds to 0. | |
| 2547 | + if (container_fps) { | |
| 2548 | + const AVTimecode tcr = { | |
| 2549 | + .start = 0, | |
| 2550 | + .flags = AV_TIMECODE_FLAG_DROPFRAME, | |
| 2551 | + .rate = av_d2q(mpctx->vo_chain->filter->container_fps, INT_MAX), | |
| 2552 | + .fps = container_fps, | |
| 2553 | + }; | |
| 2554 | + int frame = lrint(get_current_pos_ratio(mpctx, false) * get_frame_count(mpctx)); | |
| 2555 | + av_timecode_make_string(&tcr, approx_smpte, frame); | |
| 2556 | + } | |
| 2552 | 2557 | } |
| 2553 | 2558 | |
| 2554 | 2559 | struct m_sub_property props[] = { |