aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorDan Fandrich <dan@coneharvesters.com>2007-07-10 22:23:16 +0000
committerDan Fandrich <dan@coneharvesters.com>2007-07-10 22:23:16 +0000
commit93bd5123571092b2ccf925ca00cfe107e00f9f68 (patch)
treed2e41770649c319136584e86c977da41bf781fe3 /src/main.c
parent04d3a8c7144128de2886443f66c80263713b3d9e (diff)
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.
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c21
1 files changed, 19 insertions, 2 deletions
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);