[FFmpeg-cvslog] libgsm: check return value of gsm_create & avcodec_alloc_frame()

Paul B Mahol git at videolan.org
Sat Jan 28 22:24:30 CET 2012


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sat Jan 28 19:46:47 2012 +0000| [3ac99cdc412f3c02f96c752a6da4aada10f2edb6] | committer: Michael Niedermayer

libgsm: check return value of gsm_create & avcodec_alloc_frame()

Signed-off-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3ac99cdc412f3c02f96c752a6da4aada10f2edb6
---

 libavcodec/libgsm.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/libavcodec/libgsm.c b/libavcodec/libgsm.c
index 23950c0..203e360 100644
--- a/libavcodec/libgsm.c
+++ b/libavcodec/libgsm.c
@@ -55,6 +55,8 @@ static av_cold int libgsm_encode_init(AVCodecContext *avctx) {
     }
 
     avctx->priv_data = gsm_create();
+    if (!avctx->priv_data)
+        goto error;
 
     switch(avctx->codec_id) {
     case CODEC_ID_GSM:
@@ -71,8 +73,13 @@ static av_cold int libgsm_encode_init(AVCodecContext *avctx) {
 
     avctx->coded_frame= avcodec_alloc_frame();
     avctx->coded_frame->key_frame= 1;
+    if (!avctx->coded_frame)
+        goto error;
 
     return 0;
+error:
+    libgsm_encode_close();
+    return -1;
 }
 
 static av_cold int libgsm_encode_close(AVCodecContext *avctx) {



More information about the ffmpeg-cvslog mailing list