From 93bd5123571092b2ccf925ca00cfe107e00f9f68 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Tue, 10 Jul 2007 22:23:16 +0000 Subject: Fixed a curl memory leak reported by Song Ma with a modified version of the patch he suggested. Added his test case as test289 to verify. --- src/main.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 17a961ee0..4f4705059 100644 --- a/src/main.c +++ b/src/main.c @@ -4009,7 +4009,21 @@ operate(struct Configurable *config, int argc, argv_item_t argv[]) helpf("Can't open '%s'!\n", uploadfile); if(infd) fclose(infd); - return CURLE_READ_ERROR; + + /* Free the list of remaining URLs and globbed upload files + * to force curl to exit immediately + */ + if(urls) { + glob_cleanup(urls); + urls = NULL; + } + if(inglob) { + glob_cleanup(inglob); + inglob = NULL; + } + + res = CURLE_READ_ERROR; + goto quit_urls; } infdfopen=TRUE; uploadfilesize=fileinfo.st_size; @@ -4557,6 +4571,7 @@ show_error: SetComment( outs.filename, url); #endif +quit_urls: if(headerfilep) fclose(headerfilep); @@ -4571,9 +4586,11 @@ show_error: } /* loop to the next URL */ - if(urls) + if(urls) { /* cleanup memory used for URL globbing patterns */ glob_cleanup(urls); + urls = NULL; + } if(uploadfile) free(uploadfile); -- cgit v1.2.3