[Opensrf-commits] r1195 - trunk/src/libopensrf

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Dec 31 21:19:49 EST 2007


Author: miker
Date: 2007-12-31 20:56:28 -0500 (Mon, 31 Dec 2007)
New Revision: 1195

Modified:
   trunk/src/libopensrf/utils.c
Log:
Patch from Scott McKellar:

1. Plugs a memory leak in file_to_string().  If we failed to open the
file, we were returning without freeing the growing_buffer that held
the file name.

2. Replaces a couple of calls to buffer_data() with calls to
buffer_release().



Modified: trunk/src/libopensrf/utils.c
===================================================================
--- trunk/src/libopensrf/utils.c	2008-01-01 01:52:44 UTC (rev 1194)
+++ trunk/src/libopensrf/utils.c	2008-01-01 01:56:28 UTC (rev 1195)
@@ -408,9 +408,7 @@
 		idx++;
 	}
 
-	char* d = buffer_data(buf);
-	buffer_free(buf);
-	return d;
+	return buffer_release(buf);
 }
 
 
@@ -469,6 +467,7 @@
 	FILE* file = fopen(filename, "r");
 	if(!file) {
 		osrfLogError( OSRF_LOG_MARK, "Unable to open file [%s]", filename );
+		buffer_free(gb);
 		return NULL;
 	}
 
@@ -479,9 +478,7 @@
 
 	fclose(file);
 
-	char* data = buffer_data(gb);
-	buffer_free(gb);
-	return data;
+	return buffer_release(gb);
 }
 
 



More information about the opensrf-commits mailing list