PR #23060 opened by stevenliu URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23060 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23060.patch
These commits mainly fixes the four POCs in the issues. >From f32408cb06062b9f6ed648823a3efbbeae3511c6 Mon Sep 17 00:00:00 2001 From: Steven Liu <[email protected]> Date: Sat, 9 May 2026 18:19:12 +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 cf6c542d5f..abff95063f 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -598,6 +598,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 1040aae7126694be0cab03e2d3a9f3c5f7c64808 Mon Sep 17 00:00:00 2001 From: Steven Liu <[email protected]> Date: Sat, 9 May 2026 18:26:17 +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 abff95063f..1105fe0d9c 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -598,7 +598,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 c3f0b38339cc6906ab156ce91f62aab339bc2337 Mon Sep 17 00:00:00 2001 From: Steven Liu <[email protected]> Date: Sat, 9 May 2026 18:43:37 +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 1105fe0d9c..93ebe771a9 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -1501,6 +1501,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 dab1ad7f1279cb26ffbdef516f98fb543873d234 Mon Sep 17 00:00:00 2001 From: Steven Liu <[email protected]> Date: Sat, 9 May 2026 19:16:07 +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 93ebe771a9..43503c1eb8 100644 --- a/libavformat/dashdec.c +++ b/libavformat/dashdec.c @@ -857,12 +857,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); \ @@ -871,9 +873,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]
