From 6e14e2d6142c9e68b4f038f0f8dd330206ae4e8c Mon Sep 17 00:00:00 2001 From: miker Date: Tue, 1 Jan 2008 01:56:28 +0000 Subject: [PATCH] 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(). git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1195 9efc2488-bf62-4759-914b-345cdb29e865 --- src/libopensrf/utils.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/libopensrf/utils.c b/src/libopensrf/utils.c index cffaeca..4b156bb 100644 --- a/src/libopensrf/utils.c +++ b/src/libopensrf/utils.c @@ -408,9 +408,7 @@ char* uescape( const char* string, int size, int full_escape ) { idx++; } - char* d = buffer_data(buf); - buffer_free(buf); - return d; + return buffer_release(buf); } @@ -469,6 +467,7 @@ char* file_to_string(const char* filename) { 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 @@ char* file_to_string(const char* filename) { fclose(file); - char* data = buffer_data(gb); - buffer_free(gb); - return data; + return buffer_release(gb); } -- 2.11.0