Hello,
Attached patch fixes segmentation fault in libavformat/a64.c
a64_write_header() when output stream's codec is not open, so
avctx->codec is NULL (in "stream_copy" use case for example). Correct
access to codec id is use of "avctx->codec_id" instead of
"avctx->codec->id".
Additionally, in 'default' section of switch() statement here, I propose
to return AVERROR(ENOTSUP) instead of AVERROR_INVALIDDATA, because it is
more clear to get someting like
"avformat_write_header() fails: Operation not supported"
instread of
"avformat_write_header() fails: Invalid data found when processing
input"
when we do output, but do not input.
Reards,
Andrey Myznikov
>From b7d1fab99ac24b0a7a81244e24b65abb4b9059cc Mon Sep 17 00:00:00 2001
From: Andrey Myznikov <andrey.myzni...@gmail.com>
Date: Mon, 18 Aug 2014 19:18:04 +0300
Subject: [PATCH] Avoid segfault in a64_write_header() when stream codec is not
open
---
libavformat/a64.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libavformat/a64.c b/libavformat/a64.c
index 03679b2..ed27b14 100644
--- a/libavformat/a64.c
+++ b/libavformat/a64.c
@@ -40,7 +40,8 @@ static int a64_write_header(AVFormatContext *s)
return AVERROR_INVALIDDATA;
}
- switch (avctx->codec->id) {
+
+ switch (avctx->codec_id) {
case AV_CODEC_ID_A64_MULTI:
header[2] = 0x00;
header[3] = AV_RB32(avctx->extradata+0);
@@ -52,7 +53,7 @@ static int a64_write_header(AVFormatContext *s)
header[4] = 3;
break;
default:
- return AVERROR_INVALIDDATA;
+ return AVERROR(ENOTSUP);
}
avio_write(s->pb, header, 2);
return 0;
--
2.0.4
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel