Skip to main content.
home | support | download

Back to List Archive

more leak fixes

From: Antony Dovgal <antony(at)not-real.zend.com>
Date: Wed Jan 31 2007 - 15:13:54 GMT
This is a multi-part message in MIME format.
--------------070200040507060100040103
Content-Type: text/plain; charset=KOI8-R; format=flowed
Content-Transfer-Encoding: 7bit

Hello all.

In attachment you can find two more patches plugging minor leaks.

1) DB_Open_Native() may leak an allocated storage on error.
2) SwishSetSearchLimit() resets srch->limit_params to NULL when setlimit_params() fails.

-- 
Wbr, 
Antony Dovgal

--------------070200040507060100040103
Content-Type: text/plain;
 name="db_open_leak.diff.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="db_open_leak.diff.txt"

Index: src/db_native.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/db_native.c,v
retrieving revision 1.91
diff -u -p -d -r1.91 db_native.c
--- src/db_native.c	25 Aug 2006 02:49:47 -0000	1.91
+++ src/db_native.c	31 Jan 2007 14:59:55 -0000
@@ -534,6 +534,7 @@ void   *DB_Open_Native(SWISH *sw, char *
     if (!(DB->prop = openRoutine(s)))
     {
         set_progerrno(INDEX_FILE_ERROR, DB->sw, "Couldn't open the property file \"%s\": ", s);
+        efree(s);
         return (void *) DB;
     }
 
@@ -549,6 +550,7 @@ void   *DB_Open_Native(SWISH *sw, char *
     if (!(fp_tmp = openRoutine(s)))
     {
         set_progerrno(INDEX_FILE_ERROR, DB->sw, "Couldn't open the btree file \"%s\": ", s);
+        efree(s);
         return (void *) DB;
     }
 
@@ -565,6 +567,7 @@ void   *DB_Open_Native(SWISH *sw, char *
     if (!(DB->fp_presorted = openRoutine(s)))
     {
         set_progerrno(INDEX_FILE_ERROR, DB->sw, "Couldn't open the presorted index file \"%s\": ", s);
+        efree(s);
         return (void *) DB;
     }
 
@@ -581,6 +584,7 @@ void   *DB_Open_Native(SWISH *sw, char *
     if (!(fp_tmp = openRoutine(s)))
     {
         set_progerrno(INDEX_FILE_ERROR, DB->sw, "Couldn't open the worddata file \"%s\": ", s);
+        efree(s);
         return (void *) DB;
     }
 
@@ -597,6 +601,7 @@ void   *DB_Open_Native(SWISH *sw, char *
     if (!(fp_tmp = openRoutine(s)))
     {
         set_progerrno(INDEX_FILE_ERROR, DB->sw, "Couldn't open the hashfile file \"%s\": ", s);
+        efree(s);
         return (void *) DB;
     }
 
@@ -613,6 +618,7 @@ void   *DB_Open_Native(SWISH *sw, char *
     if (!(fp_tmp = openRoutine(s)))
     {
         set_progerrno(INDEX_FILE_ERROR, DB->sw, "Couldn't open the array file \"%s\": ", s);
+        efree(s);
         return (void *) DB;
     }
 

--------------070200040507060100040103
Content-Type: text/plain;
 name="set_limit_leak.diff.txt"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="set_limit_leak.diff.txt"

Index: src/proplimit.c
===================================================================
RCS file: /cvsroot/swishe/swish-e/src/proplimit.c,v
retrieving revision 1.48
diff -u -p -d -r1.48 proplimit.c
--- src/proplimit.c	12 May 2005 15:41:05 -0000	1.48
+++ src/proplimit.c	31 Jan 2007 15:01:31 -0000
@@ -238,6 +236,8 @@ void ClearLimitParams( LIMIT_PARAMS *par
 ********************************************************************/
 int SwishSetSearchLimit(SEARCH_OBJECT *srch, char *propertyname, char *low, char *hi)
 {
+    LIMIT_PARAMS *params;
+
     reset_lasterror( srch->sw );
     
     if ( srch->limits_prepared )
@@ -246,7 +246,13 @@ int SwishSetSearchLimit(SEARCH_OBJECT *s
         return 0;
     }
 
-    srch->limit_params = setlimit_params( srch->sw, srch->limit_params, propertyname, low, hi );
+    params = setlimit_params( srch->sw, srch->limit_params, propertyname, low, hi );
+	
+    if (params) 
+    {
+        srch->limit_params = params;
+    }
+
     return ( srch->sw->lasterror == 0 );
 
 }

--------------070200040507060100040103--
Received on Wed Jan 31 07:14:16 2007