PR #23482 opened by stevenliu URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23482 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23482.patch
These commits mainly fixes the four POCs in the issues in #23057. >From 86f8261545e55ec61acf8637020e27999fda6d19 Mon Sep 17 00:00:00 2001 From: Steven Liu <[email protected]> Date: Mon, 15 Jun 2026 16:47:10 +0800 Subject: [PATCH 1/4] avformat/dashdec: check NULL pointer of av_strtok value before use it fix issue: issues/23057 POC1 release seg memory and return NULL if av_strtok return NULL. Signed-off-by: Steven Liu <[email protected]> --- libavformat/dashdec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index bed82fcf45..58e06c6b29 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -600,6 +600,10 @@ static struct fragment *get_fragment(char *range) if (range) { char *str_end_offset; char *str_offset = av_strtok(range, "-", &str_end_offset); + if (!str_offset) { + av_freep(&seg); + return NULL; + } seg->url_offset = strtoll(str_offset, NULL, 10); seg->size = strtoll(str_end_offset, NULL, 10) - seg->url_offset + 1; } -- 2.52.0 >From 382c005e3a02b57c380cf58db0471cd84afbebdc Mon Sep 17 00:00:00 2001 From: Steven Liu <[email protected]> Date: Mon, 15 Jun 2026 16:47:47 +0800 Subject: [PATCH 2/4] avformat/dashdec: check NULL pointer before use str_end_offset fix issue: issues/23057 POC2 Signed-off-by: Steven Liu <[email protected]> --- libavformat/dashdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 58e06c6b29..c75722818a 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -600,7 +600,7 @@ static struct fragment *get_fragment(char *range) if (range) { char *str_end_offset; char *str_offset = av_strtok(range, "-", &str_end_offset); - if (!str_offset) { + if (!str_offset || !str_end_offset) { av_freep(&seg); return NULL; } -- 2.52.0 >From 6defa4142bbd27038012b80172d2dd843ed88b10 Mon Sep 17 00:00:00 2001 From: Steven Liu <[email protected]> Date: Mon, 15 Jun 2026 16:49:12 +0800 Subject: [PATCH 3/4] avformat/dashdec: set length_of_each_segment to 1 when it invalid fix issue: issues/23057 POC3 When the duration on the timeline is less than the fragment_timescale, the length_of_each_segment should be based on the smallest unit of 1 second. Signed-off-by: Steven Liu <[email protected]> --- libavformat/dashdec.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index c75722818a..86a22f0ca8 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -1503,6 +1503,8 @@ static int64_t calc_max_seg_no(struct representation *pls, DASHContext *c) for (i = 0; i < pls->n_timelines; i++) { if (pls->timelines[i]->repeat == -1) { int length_of_each_segment = pls->timelines[i]->duration / pls->fragment_timescale; + if (length_of_each_segment <= 0) + length_of_each_segment = 1; num = c->period_duration / length_of_each_segment; } else { num += pls->timelines[i]->repeat; -- 2.52.0 >From 7117000d259d23d86954143349d629997a3d8afd Mon Sep 17 00:00:00 2001 From: Steven Liu <[email protected]> Date: Mon, 15 Jun 2026 16:49:35 +0800 Subject: [PATCH 4/4] avformat/dashdec: set initial value of timescale and duration before read them fix issue: issues/23057 POC4 The timescale and duration are used for segment position calculations, so they should be set to meaningful non-zero values to handle cases where corresponding values cannot be read from Period, AdaptationSet, Representation, or SegmentTemplate. Signed-off-by: Steven Liu <[email protected]> --- libavformat/dashdec.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c index 86a22f0ca8..e4e0160583 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -859,12 +859,14 @@ end: } #define SET_REPRESENTATION_SEQUENCE_BASE_INFO(arg, cnt) { \ + rep->fragment_duration = 1; \ + rep->fragment_timescale = 1; \ val = get_val_from_nodes_tab((arg), (cnt), "duration"); \ if (val) { \ int64_t fragment_duration = (int64_t) strtoll(val, NULL, 10); \ - if (fragment_duration < 0) { \ - av_log(s, AV_LOG_WARNING, "duration invalid, autochanged to 0.\n"); \ - fragment_duration = 0; \ + if (fragment_duration <= 0) { \ + av_log(s, AV_LOG_WARNING, "duration invalid, autochanged to 1.\n"); \ + fragment_duration = 1; \ } \ rep->fragment_duration = fragment_duration; \ av_log(s, AV_LOG_TRACE, "rep->fragment_duration = [%"PRId64"]\n", rep->fragment_duration); \ @@ -873,9 +875,9 @@ end: val = get_val_from_nodes_tab((arg), (cnt), "timescale"); \ if (val) { \ int64_t fragment_timescale = (int64_t) strtoll(val, NULL, 10); \ - if (fragment_timescale < 0) { \ - av_log(s, AV_LOG_WARNING, "timescale invalid, autochanged to 0.\n"); \ - fragment_timescale = 0; \ + if (fragment_timescale <= 0) { \ + av_log(s, AV_LOG_WARNING, "timescale invalid, autochanged to 1.\n"); \ + fragment_timescale = 1; \ } \ rep->fragment_timescale = fragment_timescale; \ av_log(s, AV_LOG_TRACE, "rep->fragment_timescale = [%"PRId64"]\n", rep->fragment_timescale); \ -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
