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

Michael Niedermayer git at videolan.org
Tue Apr 7 13:07:34 CEST 2015


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

avutil/pca: Check for av_malloc* failures

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
(cherry picked from commit dadc43eee4d9036aa532665a04720238cc15e922)

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

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

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

diff --git a/libavutil/pca.c b/libavutil/pca.c
index 311b6bc..a745136 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(sizeof(*pca->z) * n);
     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