[MPlayer-cvslog] r37605 - trunk/libmpcodecs/ad_spdif.c

rtogni subversion at mplayerhq.hu
Sun Jan 24 19:30:16 CET 2016


Author: rtogni
Date: Sun Jan 24 19:30:16 2016
New Revision: 37605

Log:
Fix segfault with sipdif

Also fix sample reported by Gustavo Grieco
SIGSEGV.PC.5555558f165d.STACK.c27a04484.CODE.1.ADDR.(nil).INSTR.mov____(%rax),%r9.fuzz​
with -ao null

This closes trac #2277

Modified:
   trunk/libmpcodecs/ad_spdif.c

Modified: trunk/libmpcodecs/ad_spdif.c
==============================================================================
--- trunk/libmpcodecs/ad_spdif.c	Sun Jan 24 00:42:12 2016	(r37604)
+++ trunk/libmpcodecs/ad_spdif.c	Sun Jan 24 19:30:16 2016	(r37605)
@@ -45,6 +45,7 @@ struct spdifContext {
     int              out_buffer_size;
     uint8_t         *out_buffer;
     uint8_t          pb_buffer[OUTBUF_SIZE];
+    int              header_written;
 };
 
 static int read_packet(void *p, uint8_t *buf, int buf_size)
@@ -78,7 +79,7 @@ static int preinit(sh_audio_t *sh)
 
 static int init(sh_audio_t *sh)
 {
-    int i, x, in_size, srate, bps, *dtshd_rate;
+    int i, x, in_size, srate, bps, *dtshd_rate, res;
     unsigned char *start;
     double pts;
     static const struct {
@@ -129,11 +130,13 @@ static int init(sh_audio_t *sh)
             break;
         }
     }
-    if (AVERROR_PATCHWELCOME == lavf_ctx->oformat->write_header(lavf_ctx)) {
-        mp_msg(MSGT_DECAUDIO,MSGL_INFO,
+    if ((res = avformat_write_header(lavf_ctx, NULL)) < 0) {
+        if (res == AVERROR_PATCHWELCOME)
+            mp_msg(MSGT_DECAUDIO,MSGL_INFO,
                "This codec is not supported by spdifenc.\n");
         goto fail;
     }
+    spdif_ctx->header_written = 1;
 
     // get sample_rate & bitrate from parser
     x = ds_get_packet_pts(sh->ds, &start, &pts);
@@ -292,8 +295,8 @@ static void uninit(sh_audio_t *sh)
     AVFormatContext     *lavf_ctx  = spdif_ctx->lavf_ctx;
 
     if (lavf_ctx) {
-        if (lavf_ctx->oformat)
-            lavf_ctx->oformat->write_trailer(lavf_ctx);
+        if (spdif_ctx->header_written)
+            av_write_trailer(lavf_ctx);
         av_freep(&lavf_ctx->pb);
         if (lavf_ctx->streams) {
             av_freep(&lavf_ctx->streams[0]->codec);


More information about the MPlayer-cvslog mailing list