diff mbox series

[FFmpeg-devel,2/2] lavf/mpegts: fix av_log use the uninitialized stream id

Message ID 20210507130334.31002-2-mypopydev@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/2] doc/filters: Update commands doc for amix
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Jun Zhao May 7, 2021, 1:03 p.m. UTC
From: Jun Zhao <barryjzhao@tencent.com>

fix av_log use the uninitialized stream id

Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
---
 libavformat/mpegts.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Marton Balint May 9, 2021, 10:32 p.m. UTC | #1
On Fri, 7 May 2021, Jun Zhao wrote:

> From: Jun Zhao <barryjzhao@tencent.com>
>
> fix av_log use the uninitialized stream id

Actually i is not the correct value even if it is initialized because the 
loop is executed in full.

Either remove remove logging the stream index, it is not super useful 
anyway, or rework the function to find an index instead of an AVStream*, 
that way you can log it cleanly and in the end return something like:

return found_idx == -1 ? NULL : s->streams[p->streams[found_idx].idx];

But it is also fine if you simply remove the PMT stream index logging.

Thanks,
Marton

>
> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
> ---
> libavformat/mpegts.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 9092dbce72..722dae8e36 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -2207,7 +2207,7 @@ static AVStream *find_matching_stream(MpegTSContext *ts, int pid, unsigned int p
>                                       int stream_identifier, int pmt_stream_idx, struct Program *p)
> {
>     AVFormatContext *s = ts->stream;
> -    int i;
> +    int i; // the stream id of the match
>     AVStream *found = NULL;
>
>     if (stream_identifier) { /* match based on "stream identifier descriptor" if present */
> @@ -2218,6 +2218,7 @@ static AVStream *find_matching_stream(MpegTSContext *ts, int pid, unsigned int p
>         }
>     } else if (pmt_stream_idx < p->nb_streams) { /* match based on position within the PMT */
>         found = s->streams[p->streams[pmt_stream_idx].idx];
> +        i = pmt_stream_idx;
>     }
>
>     if (found) {
> -- 
> 2.17.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
mypopy@gmail.com May 10, 2021, 12:41 p.m. UTC | #2
On Mon, May 10, 2021 at 6:33 AM Marton Balint <cus@passwd.hu> wrote:
>
>
>
> On Fri, 7 May 2021, Jun Zhao wrote:
>
> > From: Jun Zhao <barryjzhao@tencent.com>
> >
> > fix av_log use the uninitialized stream id
>
> Actually i is not the correct value even if it is initialized because the
> loop is executed in full.
>
> Either remove remove logging the stream index, it is not super useful
> anyway, or rework the function to find an index instead of an AVStream*,
> that way you can log it cleanly and in the end return something like:
>
> return found_idx == -1 ? NULL : s->streams[p->streams[found_idx].idx];
>
> But it is also fine if you simply remove the PMT stream index logging.
Will follow the comments, thx
>
> Thanks,
> Marton
>
diff mbox series

Patch

diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index 9092dbce72..722dae8e36 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -2207,7 +2207,7 @@  static AVStream *find_matching_stream(MpegTSContext *ts, int pid, unsigned int p
                                       int stream_identifier, int pmt_stream_idx, struct Program *p)
 {
     AVFormatContext *s = ts->stream;
-    int i;
+    int i; // the stream id of the match
     AVStream *found = NULL;
 
     if (stream_identifier) { /* match based on "stream identifier descriptor" if present */
@@ -2218,6 +2218,7 @@  static AVStream *find_matching_stream(MpegTSContext *ts, int pid, unsigned int p
         }
     } else if (pmt_stream_idx < p->nb_streams) { /* match based on position within the PMT */
         found = s->streams[p->streams[pmt_stream_idx].idx];
+        i = pmt_stream_idx;
     }
 
     if (found) {