History

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.

Mohammad AlSaleh committed 2 years ago

Commit 28a4e191 parent 2ac1d6d1 file · +13 −8Browse files

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t