[FFmpeg-devel] [PATCH] Check malloc values in swscale.

Reimar Döffinger Reimar.Doeffinger
Mon Aug 17 08:13:12 CEST 2009


On Sun, Aug 16, 2009 at 09:41:06PM -0300, Ramiro Polla wrote:
> diff --git a/swscale.c b/swscale.c
> index 6dfbed7..58db7bb 100644
> --- a/swscale.c
> +++ b/swscale.c
> @@ -3259,12 +3259,14 @@ SwsVector *sws_getGaussianVec(double variance, double quality)
>      double middle= (length-1)*0.5;
>      SwsVector *vec= sws_allocVec(length);
>  
> +    if (vec) {
>      for (i=0; i<length; i++) {
>          double dist= i-middle;
>          vec->coeff[i]= exp(-dist*dist/(2*variance*variance)) / sqrt(2*variance*PI);
>      }
>  
>      sws_normalizeVec(vec, 1.0);
> +    }
>  
>      return vec;

don't like that at all. It makes the code more complex by adding an
extra indentation level (and the need to reindent here) while also
suggesting that the vec == NULL case is somehow handled when it is
just I-can't-do-anything emergency bailout.
So "if (!vec) return NULL;" seems more appropriate (yes, my suggested
alloc function doesn't do that, but only because it would add extra
code).



More information about the ffmpeg-devel mailing list