From 0dd6522036daa8468c55c4a0c6b70d1c510e879a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 28 Nov 2013 23:31:31 +0100 Subject: [PATCH] globbing: curl glob counter mismatch with {} list use The "fixed string" function wrongly bumped the "urlnum" counter which made curl output the total number of URLs wrong when using {one,two,three} lists in globs. Reported-by: Michael-O Bug: http://curl.haxx.se/bug/view.cgi?id=1305 --- src/tool_urlglob.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/tool_urlglob.c b/src/tool_urlglob.c index aa87e5a37..ec5014b97 100644 --- a/src/tool_urlglob.c +++ b/src/tool_urlglob.c @@ -40,8 +40,7 @@ typedef enum { void glob_cleanup(URLGlob* glob); -static GlobCode glob_fixed(URLGlob *glob, unsigned long *amount, - char *fixed, size_t len) +static GlobCode glob_fixed(URLGlob *glob, char *fixed, size_t len) { URLPattern *pat = &glob->pattern[glob->size]; pat->type = UPTSet; @@ -49,8 +48,6 @@ static GlobCode glob_fixed(URLGlob *glob, unsigned long *amount, pat->content.Set.ptr_s = 0; pat->globindex = -1; - (*amount)++; - pat->content.Set.elements = malloc(sizeof(char*)); if(!pat->content.Set.elements) @@ -314,6 +311,8 @@ static GlobCode glob_parse(URLGlob *glob, char *pattern, GlobCode res = GLOB_OK; int globindex = 0; /* count "actual" globs */ + *amount = 1; + while(*pattern && !res) { char *buf = glob->glob_buffer; int sublen = 0; @@ -337,12 +336,9 @@ static GlobCode glob_parse(URLGlob *glob, char *pattern, if(sublen) { /* we got a literal string, add it as a single-item list */ *buf = '\0'; - res = glob_fixed(glob, amount, glob->glob_buffer, sublen); + res = glob_fixed(glob, glob->glob_buffer, sublen); } else { - if(!*amount) - *amount = 1; - switch (*pattern) { case '\0': /* done */ break;