changeset 27300:181f489ead9d

fix memleak
author michael
date Mon, 21 Jul 2008 11:41:13 +0000
parents 4e57d47ee5db
children 19fef8a7d0ab
files libswscale/swscale.c
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libswscale/swscale.c	Mon Jul 21 11:18:24 2008 +0000
+++ b/libswscale/swscale.c	Mon Jul 21 11:41:13 2008 +0000
@@ -932,6 +932,7 @@
     int minFilterSize;
     double *filter=NULL;
     double *filter2=NULL;
+    int ret= -1;
 #if defined(ARCH_X86)
     if (flags & SWS_CPU_CAPS_MMX)
         asm volatile("emms\n\t"::: "memory"); //FIXME this should not be required but it IS (even for non-MMX versions)
@@ -1211,8 +1212,8 @@
     filterSize= (minFilterSize +(filterAlign-1)) & (~(filterAlign-1));
     assert(filterSize > 0);
     filter= av_malloc(filterSize*dstW*sizeof(double));
-    if (filterSize >= MAX_FILTER_SIZE)
-        return -1;
+    if (filterSize >= MAX_FILTER_SIZE || !filter)
+        goto error;
     *outFilterSize= filterSize;
 
     if (flags&SWS_PRINT_INFO)
@@ -1228,7 +1229,6 @@
             else               filter[i*filterSize + j]= filter2[i*filter2Size + j];
         }
     }
-    av_freep(&filter2);
 
 
     //FIXME try to align filterpos if possible
@@ -1296,8 +1296,11 @@
         (*outFilter)[j + i]= (*outFilter)[j + i - (*outFilterSize)];
     }
 
+    ret=0;
+error:
     av_free(filter);
-    return 0;
+    av_free(filter2);
+    return ret;
 }
 
 #ifdef COMPILE_MMX2