[libav-devel] [PATCH] ogg: check malloc calls

Nidhi Makhijani nidhimj22 at gmail.com
Sun Jun 1 14:30:15 CEST 2014


---
 libavformat/oggparsespeex.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/oggparsespeex.c b/libavformat/oggparsespeex.c
index 6d70e99..df2bd6c 100644
--- a/libavformat/oggparsespeex.c
+++ b/libavformat/oggparsespeex.c
@@ -47,6 +47,8 @@ static int speex_header(AVFormatContext *s, int idx) {
 
     if (!spxp) {
         spxp = av_mallocz(sizeof(*spxp));
+        if (!spxp)
+            return AVERROR(ENOMEM);
         os->private = spxp;
     }
 
@@ -75,6 +77,10 @@ static int speex_header(AVFormatContext *s, int idx) {
         st->codec->extradata_size = os->psize;
         st->codec->extradata = av_malloc(st->codec->extradata_size
                                          + FF_INPUT_BUFFER_PADDING_SIZE);
+        if (!st->codec->extradata) {
+            av_freep(spxp);
+            return AVERROR(ENOMEM);
+        }
         memcpy(st->codec->extradata, p, st->codec->extradata_size);
 
         avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
-- 
1.9.1



More information about the libav-devel mailing list