aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/a64multienc.c
diff options
context:
space:
mode:
authorTobias Bindhammer <tobias.bindhammer@uni-ulm.de>2010-08-31 07:14:47 +0000
committerTobias Bindhammer <tobias.bindhammer@uni-ulm.de>2010-08-31 07:14:47 +0000
commitd1cacdb8dda4eb2a5532267b0aeb1d2afdf95f05 (patch)
tree3ac9a39e8e171764c99f679a7e2f7d522377ebea /libavcodec/a64multienc.c
parent99d7a3e862ec0d15903f99f6b94d152ca1834f0f (diff)
downloadffmpeg-d1cacdb8dda4eb2a5532267b0aeb1d2afdf95f05.tar.gz
Checking return values of av_malloc(z) and report an error in case.
Originally committed as revision 25003 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/a64multienc.c')
-rw-r--r--libavcodec/a64multienc.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c
index 4571f052b8..5e127e1515 100644
--- a/libavcodec/a64multienc.c
+++ b/libavcodec/a64multienc.c
@@ -192,14 +192,21 @@ static av_cold int a64multi_init_encoder(AVCodecContext *avctx)
c->mc_frame_counter = 0;
c->mc_use_5col = avctx->codec->id == CODEC_ID_A64_MULTI5;
- c->mc_meta_charset = av_malloc (32000 * c->mc_lifetime * sizeof(int));
- c->mc_best_cb = av_malloc (CHARSET_CHARS * 32 * sizeof(int));
- c->mc_charmap = av_mallocz(1000 * c->mc_lifetime * sizeof(int));
- c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t));
- c->mc_charset = av_malloc (0x800 * (INTERLACED+1) * sizeof(uint8_t));
+
+ if(!(c->mc_meta_charset = av_malloc (32000 * c->mc_lifetime * sizeof(int))) ||
+ !(c->mc_best_cb = av_malloc (CHARSET_CHARS * 32 * sizeof(int))) ||
+ !(c->mc_charmap = av_mallocz(1000 * c->mc_lifetime * sizeof(int))) ||
+ !(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t))) ||
+ !(c->mc_charset = av_malloc (0x800 * (INTERLACED+1) * sizeof(uint8_t)))) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to allocate buffer memory.\n");
+ return AVERROR(ENOMEM);
+ }
/* set up extradata */
- avctx->extradata = av_mallocz(8 * 4 + FF_INPUT_BUFFER_PADDING_SIZE);
+ if(!(avctx->extradata = av_mallocz(8 * 4 + FF_INPUT_BUFFER_PADDING_SIZE))) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to allocate memory for extradata.\n");
+ return AVERROR(ENOMEM);
+ }
avctx->extradata_size = 8 * 4;
AV_WB32(avctx->extradata, c->mc_lifetime);
AV_WB32(avctx->extradata+16, INTERLACED);