From 1b03a9d6073b3a4c62a44b56852762eb4b382dc4 Mon Sep 17 00:00:00 2001 From: Ramiro Polla Date: Thu, 20 Aug 2009 01:55:45 +0000 Subject: [PATCH] Check return values of sws_allocVec() and sws_getConstVec(). Originally committed as revision 29543 to svn://svn.mplayerhq.hu/mplayer/trunk/libswscale --- libswscale/swscale.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 6dfbed7..2f5d5f1 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -3259,6 +3259,9 @@ SwsVector *sws_getGaussianVec(double variance, double quality) double middle= (length-1)*0.5; SwsVector *vec= sws_allocVec(length); + if (!vec) + return NULL; + for (i=0; icoeff[i]= exp(-dist*dist/(2*variance*variance)) / sqrt(2*variance*PI); @@ -3274,6 +3277,9 @@ SwsVector *sws_getConstVec(double c, int length) int i; SwsVector *vec= sws_allocVec(length); + if (!vec) + return NULL; + for (i=0; icoeff[i]= c; @@ -3316,6 +3322,9 @@ static SwsVector *sws_getConvVec(SwsVector *a, SwsVector *b) int i, j; SwsVector *vec= sws_getConstVec(0.0, length); + if (!vec) + return NULL; + for (i=0; ilength; i++) { for (j=0; jlength; j++) { vec->coeff[i+j]+= a->coeff[i]*b->coeff[j]; @@ -3331,6 +3340,9 @@ static SwsVector *sws_sumVec(SwsVector *a, SwsVector *b) int i; SwsVector *vec= sws_getConstVec(0.0, length); + if (!vec) + return NULL; + for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i]; for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (b->length-1)/2]+= b->coeff[i]; @@ -3343,6 +3355,9 @@ static SwsVector *sws_diffVec(SwsVector *a, SwsVector *b) int i; SwsVector *vec= sws_getConstVec(0.0, length); + if (!vec) + return NULL; + for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (a->length-1)/2]+= a->coeff[i]; for (i=0; ilength; i++) vec->coeff[i + (length-1)/2 - (b->length-1)/2]-= b->coeff[i]; @@ -3356,6 +3371,9 @@ static SwsVector *sws_getShiftedVec(SwsVector *a, int shift) int i; SwsVector *vec= sws_getConstVec(0.0, length); + if (!vec) + return NULL; + for (i=0; ilength; i++) { vec->coeff[i + (length-1)/2 - (a->length-1)/2 - shift]= a->coeff[i]; } @@ -3404,6 +3422,9 @@ SwsVector *sws_cloneVec(SwsVector *a) int i; SwsVector *vec= sws_allocVec(a->length); + if (!vec) + return NULL; + for (i=0; ilength; i++) vec->coeff[i]= a->coeff[i]; return vec; -- 2.7.4