summaryrefslogtreecommitdiff
path: root/libavformat/tty.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2011-06-03 20:43:48 +0200
committerAnton Khirnov <anton@khirnov.net>2011-06-04 19:53:45 +0200
commit8346f60afbb23b9a3dcef8e6683060f71ec296e2 (patch)
tree6c0955f325fafa157bf55d97f7836ca8f63e30ca /libavformat/tty.c
parente762b1ce9505511b1ecbbd4868ec6879e32e8831 (diff)
tty: factorise returning error codes.
Diffstat (limited to 'libavformat/tty.c')
-rw-r--r--libavformat/tty.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/libavformat/tty.c b/libavformat/tty.c
index 432fcc0c3d..9dada16b8a 100644
--- a/libavformat/tty.c
+++ b/libavformat/tty.c
@@ -73,21 +73,20 @@ static int read_header(AVFormatContext *avctx,
AVFormatParameters *ap)
{
TtyDemuxContext *s = avctx->priv_data;
- int width = 0, height = 0, ret;
+ int width = 0, height = 0, ret = 0;
AVStream *st = av_new_stream(avctx, 0);
- if (!st)
- return AVERROR(ENOMEM);
+
+ if (!st) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
st->codec->codec_tag = 0;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_ANSI;
- if (s->video_size) {
- ret = av_parse_video_size(&width, &height, s->video_size);
- av_freep(&s->video_size);
- if (ret < 0) {
- av_log (avctx, AV_LOG_ERROR, "Couldn't parse video size.\n");
- return ret;
- }
+ if (s->video_size && (ret = av_parse_video_size(&width, &height, s->video_size)) < 0) {
+ av_log (avctx, AV_LOG_ERROR, "Couldn't parse video size.\n");
+ goto fail;
}
#if FF_API_FORMAT_PARAMETERS
if (ap->width > 0)
@@ -121,7 +120,9 @@ static int read_header(AVFormatContext *avctx,
avio_seek(avctx->pb, 0, SEEK_SET);
}
- return 0;
+fail:
+ av_freep(&s->video_size);
+ return ret;
}
static int read_packet(AVFormatContext *avctx, AVPacket *pkt)