avutil/pca: Check for av_malloc* failures

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

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2015-03-30 04:37:42 +02:00
parent 99a6924983
commit 44d447f31c
1 changed files with 8 additions and 0 deletions

View File

@ -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;
}