changeset 12301:a2dfd6f9a580 libavcodec

Add 2 failed memory allocation checks
author jbr
date Fri, 30 Jul 2010 18:34:39 +0000
parents c13e3c23d093
children 2e28769c55a9
files flacenc.c
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flacenc.c	Fri Jul 30 18:30:09 2010 +0000
+++ b/flacenc.c	Fri Jul 30 18:34:39 2010 +0000
@@ -404,6 +404,8 @@
     av_md5_init(s->md5ctx);
 
     streaminfo = av_malloc(FLAC_STREAMINFO_SIZE);
+    if (!streaminfo)
+        return AVERROR(ENOMEM);
     write_streaminfo(s, streaminfo);
     avctx->extradata = streaminfo;
     avctx->extradata_size = FLAC_STREAMINFO_SIZE;
@@ -412,6 +414,8 @@
     s->min_framesize = s->max_framesize;
 
     avctx->coded_frame = avcodec_alloc_frame();
+    if (!avctx->coded_frame)
+        return AVERROR(ENOMEM);
     avctx->coded_frame->key_frame = 1;
 
     return 0;