summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-12 17:28:22 +0100
committerAlessandro Ghedini <alessandro@ghedini.me>2014-12-17 20:09:24 +0100
commit34e504bf93996058425a2cdb884b7dd4576cda68 (patch)
treee1cff050ed153613f42697a114fcd2e2576214a0
parentf0649ce841e717d907bfd28b90cf4c792aa5254f (diff)
downloadmpv-34e504bf93996058425a2cdb884b7dd4576cda68.tar.bz2
mpv-34e504bf93996058425a2cdb884b7dd4576cda68.tar.xz
Check some mallocs
Fixes #1337.
-rw-r--r--demux/demux_lavf.c4
-rw-r--r--video/decode/vd_lavc.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c
index 62dcdf3655..e1800295cc 100644
--- a/demux/demux_lavf.c
+++ b/demux/demux_lavf.c
@@ -286,6 +286,8 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check)
.buf_size = 0,
.buf = av_mallocz(PROBE_BUF_SIZE + FF_INPUT_BUFFER_PADDING_SIZE),
};
+ if (!avpd.buf)
+ return -1;
bool final_probe = false;
do {
@@ -679,6 +681,8 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check)
return -1;
avfc = avformat_alloc_context();
+ if (!avfc)
+ return -1;
if (lavfdopts->cryptokey)
parse_cryptokey(avfc, lavfdopts->cryptokey);
diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c
index 7ac92d6901..02b9c25b27 100644
--- a/video/decode/vd_lavc.c
+++ b/video/decode/vd_lavc.c
@@ -353,6 +353,8 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
ctx->hwdec_fmt = 0;
ctx->avctx = avcodec_alloc_context3(lavc_codec);
AVCodecContext *avctx = ctx->avctx;
+ if (!ctx->avctx)
+ return;
avctx->bit_rate = 0;
avctx->opaque = vd;
avctx->codec_type = AVMEDIA_TYPE_VIDEO;
@@ -360,6 +362,8 @@ static void init_avctx(struct dec_video *vd, const char *decoder,
avctx->refcounted_frames = 1;
ctx->pic = av_frame_alloc();
+ if (!ctx->pic)
+ return;
if (ctx->hwdec) {
avctx->thread_count = 1;