[FFmpeg-devel] Segfault calling av_interleaved_write_frame

2020-01-18 Thread Jonathan Noble
Hello,

I found I was getting sigsegv when calling av_interleaved_write_frame().

From a18f4cb5b86392c5c161878daea8e4b1204881eb Mon Sep 17 00:00:00 2001
From: jon noble 
Date: Sat, 18 Jan 2020 21:33:11 +
Subject: [PATCH] libavformat/mux: prevent segfault in
 compute_muxer_pkt_fields()

---
 libavformat/mux.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavformat/mux.c b/libavformat/mux.c
index 8ab5ea8c2b..ea79981fe8 100644
--- a/libavformat/mux.c
+++ b/libavformat/mux.c
@@ -598,9 +598,11 @@ static int compute_muxer_pkt_fields(AVFormatContext
*s, AVStream *st, AVPacket *
 av_log(s, AV_LOG_WARNING, "Encoder did not produce proper pts,
making some up.\n");
 warned = 1;
 }
-pkt->dts =
-//pkt->pts= st->cur_dts;
-pkt->pts = st->internal->priv_pts->val;
+if (st->internal->priv_pts == NULL) {
+  av_log(s, AV_LOG_WARNING, "Null private stream data.\n");
+  return AVERROR(EINVAL);
+}
+pkt->dts = pkt->pts = st->internal->priv_pts->val;
 }

 //calculate dts from pts
-- 
2.25.0

Kind regards

Jon
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] Segfault calling av_interleaved_write_frame

2020-01-18 Thread Jonathan Noble
Oh, it wasn't via ffmpeg. I was using the library. What is the correct dev
mailing list?

On Sat, 18 Jan 2020 at 21:45, Andreas Rheinhardt <
andreas.rheinha...@gmail.com> wrote:

> On Sat, Jan 18, 2020 at 10:40 PM Jonathan Noble 
> wrote:
>
> > Hello,
> >
> > I found I was getting sigsegv when calling av_interleaved_write_frame().
> >
> > From a18f4cb5b86392c5c161878daea8e4b1204881eb Mon Sep 17 00:00:00 2001
> > From: jon noble 
> > Date: Sat, 18 Jan 2020 21:33:11 +
> > Subject: [PATCH] libavformat/mux: prevent segfault in
> >  compute_muxer_pkt_fields()
> >
> > ---
> >  libavformat/mux.c | 8 +---
> >  1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavformat/mux.c b/libavformat/mux.c
> > index 8ab5ea8c2b..ea79981fe8 100644
> > --- a/libavformat/mux.c
> > +++ b/libavformat/mux.c
> > @@ -598,9 +598,11 @@ static int compute_muxer_pkt_fields(AVFormatContext
> > *s, AVStream *st, AVPacket *
> >  av_log(s, AV_LOG_WARNING, "Encoder did not produce proper
> pts,
> > making some up.\n");
> >  warned = 1;
> >  }
> > -pkt->dts =
> > -//pkt->pts= st->cur_dts;
> > -pkt->pts = st->internal->priv_pts->val;
> > +if (st->internal->priv_pts == NULL) {
> > +  av_log(s, AV_LOG_WARNING, "Null private stream data.\n");
> > +  return AVERROR(EINVAL);
> > +}
> > +pkt->dts = pkt->pts = st->internal->priv_pts->val;
> >  }
> >
> >  //calculate dts from pts
> > --
> > 2.25.0
> >
> > Can you give us the command line together with the necessary sample files
> that allow to reproduce this segfault?
>
> - Andreas
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] Segfault calling av_interleaved_write_frame

2020-01-19 Thread Jonathan Noble
On Sat, 18 Jan 2020 at 22:20, Nicolas George  wrote:

> Jonathan Noble (12020-01-18):
> > Oh, it wasn't via ffmpeg. I was using the library. What is the correct
> dev
> > mailing list?
>
> Probably. We would need to see the code with the sample, to be sure
> where the bug lies.
>
I'm writing a wrapper around libav.
https://github.com/jonno85uk/mediahandling/tree/Issue4_encoding
I know what was causing this condition,  avformat_write_header() hadn't
been called at that time.

>
> > On Sat, 18 Jan 2020 at 21:45, Andreas Rheinhardt <
> > andreas.rheinha...@gmail.com> wrote:
>
> Top-posting is not allowed on this mailing-list. If you do not know what
> it means, look it up.
>
> Regards,
>
> --
>   Nicolas George
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] Segfault calling av_interleaved_write_frame

2020-01-19 Thread Jonathan Noble
On Sun, 19 Jan 2020 at 11:52, Nicolas George  wrote:

> Jonathan Noble (12020-01-19):
> > I'm writing a wrapper around libav.
> > https://github.com/jonno85uk/mediahandling/tree/Issue4_encoding
> > I know what was causing this condition,  avformat_write_header() hadn't
> > been called at that time.
>
> Calling avformat_write_header() is not optional, writing frames before
> it is not supported.

I'd gathered that, but rather than bombing out shouldn't there be a AVERROR
returned or something else to notify the user of their error, like so many
other non-optional checks in ffmpeg?

>
> For questions about the proper usage of the API, see this mailing-list:
> https://ffmpeg.org/mailman/listinfo/libav-user
>
> Regards,
>
> --
>   Nicolas George
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] Segfault calling av_interleaved_write_frame

2020-01-20 Thread Jonathan Noble
On Sun, 19 Jan 2020 at 22:54, Nicolas George  wrote:

> Jonathan Noble (12020-01-19):
> > I'd gathered that, but rather than bombing out shouldn't there be a
> AVERROR
> > returned or something else to notify the user of their error, like so
> many
> > other non-optional checks in ffmpeg?
>
> No. AVERROR codes are not for errors that can be detected statically;
> these need to be fixed, period.
>
> This is not specific to FFmpeg: what do you get for calling fprintf() on
> a NULL FILE pointer?
>
I wouldn't know. I try my best not to use C.

> Regards,
>
> --
>   Nicolas George
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".