[FFmpeg-cvslog] avutil/pca: Check for av_malloc* failures

Michael Niedermayer git at videolan.org
Mon Mar 30 05:04:57 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Mon Mar 30 04:37:42 2015 +0200| [dadc43eee4d9036aa532665a04720238cc15e922] | committer: Michael Niedermayer

avutil/pca: Check for av_malloc* failures

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libavutil/pca.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/libavutil/pca.c b/libavutil/pca.c
index f7ae350..1d88ff3 100644
--- a/libavutil/pca.c
+++ b/libavutil/pca.c
@@ -41,12 +41,20 @@ PCA *ff_pca_init(int n){
         return NULL;
 
     pca= av_mallocz(sizeof(*pca));
+    if (!pca)
+        return NULL;
+
     pca->n= n;
     pca->z = av_malloc_array(n, sizeof(*pca->z));
     pca->count=0;
     pca->covariance= av_calloc(n*n, sizeof(double));
     pca->mean= av_calloc(n, sizeof(double));
 
+    if (!pca->z || !pca->covariance || !pca->mean) {
+        ff_pca_free(pca);
+        return NULL;
+    }
+
     return pca;
 }
 



More information about the ffmpeg-cvslog mailing list