]> git.sesse.net Git - vlc/commitdiff
Fix potential memleaks (CID 222 and 221)
authorRémi Duraffort <ivoire@videolan.org>
Wed, 1 Oct 2008 19:43:48 +0000 (21:43 +0200)
committerRémi Duraffort <ivoire@videolan.org>
Wed, 1 Oct 2008 19:45:08 +0000 (21:45 +0200)
modules/video_filter/gradient.c

index cb5e4d22b448b69bb02d8002b1174bf201ff3566..dc203afe2423883e7c81897046609656d9e06d02 100644 (file)
@@ -635,16 +635,27 @@ static void FilterHough( filter_t *p_filter, picture_t *p_inpic,
     double d_sin;
     double d_cos;
     uint32_t *p_smooth;
+
     int *p_hough = malloc( i_diag * i_nb_steps * sizeof(int) );
     if( ! p_hough ) return;
+
     p_smooth = (uint32_t *)malloc( i_num_lines*i_src_visible*sizeof(uint32_t));
-    if( !p_smooth ) return;
+    if( !p_smooth )
+    {
+        free( p_hough );
+        return;
+    }
 
     if( ! p_pre_hough )
     {
         msg_Dbg(p_filter, "Starting precalculation");
         p_pre_hough = malloc( i_num_lines*i_src_visible*i_nb_steps*sizeof(int));
-        if( ! p_pre_hough ) return;
+        if( ! p_pre_hough )
+        {
+            free( p_smooth );
+            free( p_hough );
+            return;
+        }
         for( i = 0 ; i < i_nb_steps ; i++)
         {
             d_sin = sin(d_step * i);