[FFmpeg-cvslog] lavc/bink: Chech for malloc failure
James Almer
git at videolan.org
Mon Feb 25 11:59:25 CET 2013
ffmpeg | branch: release/1.0 | James Almer <jamrial at gmail.com> | Tue Feb 5 22:34:29 2013 -0300| [62e55034077d60ed84e962a287069a60aecbaab6] | committer: James Almer
lavc/bink: Chech for malloc failure
Based on commit 8ab2173ed141aa2c3336be7f9880340dfb8dcf5e
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=62e55034077d60ed84e962a287069a60aecbaab6
---
libavcodec/bink.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/libavcodec/bink.c b/libavcodec/bink.c
index 9990700..c06348a 100644
--- a/libavcodec/bink.c
+++ b/libavcodec/bink.c
@@ -169,7 +169,7 @@ static void init_lengths(BinkContext *c, int width, int bw)
*
* @param c decoder context
*/
-static av_cold void init_bundles(BinkContext *c)
+static av_cold int init_bundles(BinkContext *c)
{
int bw, bh, blocks;
int i;
@@ -180,8 +180,12 @@ static av_cold void init_bundles(BinkContext *c)
for (i = 0; i < BINKB_NB_SRC; i++) {
c->bundle[i].data = av_malloc(blocks * 64);
+ if (!c->bundle[i].data)
+ return AVERROR(ENOMEM);
c->bundle[i].data_end = c->bundle[i].data + blocks * 64;
}
+
+ return 0;
}
/**
@@ -1272,7 +1276,7 @@ static av_cold int decode_init(AVCodecContext *avctx)
BinkContext * const c = avctx->priv_data;
static VLC_TYPE table[16 * 128][2];
static int binkb_initialised = 0;
- int i;
+ int i, ret;
int flags;
c->version = avctx->codec_tag >> 24;
@@ -1307,7 +1311,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
ff_dsputil_init(&c->dsp, avctx);
ff_binkdsp_init(&c->bdsp);
- init_bundles(c);
+ if ((ret = init_bundles(c)) < 0) {
+ free_bundles(c);
+ return ret;
+ }
if (c->version == 'b') {
if (!binkb_initialised) {
More information about the ffmpeg-cvslog
mailing list