1
0
mirror of https://github.com/moparisthebest/curl synced 2024-08-13 17:03:50 -04:00

Fixed a logic error in the last patch and another out of memory issue.

Reduce the scope of some variables.
This commit is contained in:
Dan Fandrich 2007-05-02 00:50:06 +00:00
parent 19a80add95
commit eec105daba

View File

@ -3411,7 +3411,8 @@ CURLcode _my_setopt(CURL *curl, const char *name, CURLoption tag, ...)
if (!bufp || !curl_slist_append(easycode, bufp)) if (!bufp || !curl_slist_append(easycode, bufp))
ret = CURLE_OUT_OF_MEMORY; ret = CURLE_OUT_OF_MEMORY;
curl_free(bufp); if (bufp)
curl_free(bufp);
va_end(arg); va_end(arg);
return ret; return ret;
@ -3494,22 +3495,15 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
struct OutStruct heads; struct OutStruct heads;
struct InStruct input; struct InStruct input;
char *url = NULL;
URLGlob *urls=NULL; URLGlob *urls=NULL;
URLGlob *inglob=NULL; URLGlob *inglob=NULL;
int urlnum; int urlnum;
int infilenum; int infilenum;
char *outfiles=NULL;
char *infiles; /* might a glob pattern */
char *uploadfile=NULL; /* a single file, never a glob */ char *uploadfile=NULL; /* a single file, never a glob */
int separator = 0;
FILE *infd = stdin; FILE *infd = stdin;
bool infdfopen; bool infdfopen;
FILE *headerfilep = NULL; FILE *headerfilep = NULL;
char *urlbuffer=NULL;
curl_off_t uploadfilesize; /* -1 means unknown */ curl_off_t uploadfilesize; /* -1 means unknown */
bool stillflags=TRUE; bool stillflags=TRUE;
@ -3520,12 +3514,8 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
CURL *curl; CURL *curl;
int res = 0; int res = 0;
int i; int i;
int up; /* upload file counter within a single upload glob */
long retry_sleep_default; long retry_sleep_default;
long retry_numretries;
long retry_sleep; long retry_sleep;
long response;
struct timeval retrystart;
char *env; char *env;
#ifdef CURLDEBUG #ifdef CURLDEBUG
@ -3751,7 +3741,11 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
/* loop through the list of given URLs */ /* loop through the list of given URLs */
while(urlnode) { while(urlnode) {
int up; /* upload file counter within a single upload glob */
char *dourl; char *dourl;
char *url;
char *infiles; /* might be a glob pattern */
char *outfiles=NULL;
/* get the full URL (it might be NULL) */ /* get the full URL (it might be NULL) */
dourl=urlnode->url; dourl=urlnode->url;
@ -3807,6 +3801,8 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
glob_next_url(inglob): glob_next_url(inglob):
(!up?strdup(infiles):NULL)); (!up?strdup(infiles):NULL));
up++) { up++) {
int separator = 0;
long retry_numretries;
uploadfilesize=-1; uploadfilesize=-1;
if(!config->globoff) { if(!config->globoff) {
@ -3830,6 +3826,7 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
(url = urls?glob_next_url(urls):(i?NULL:strdup(url))); (url = urls?glob_next_url(urls):(i?NULL:strdup(url)));
i++) { i++) {
char *outfile; char *outfile;
struct timeval retrystart;
outfile = outfiles?strdup(outfiles):NULL; outfile = outfiles?strdup(outfiles):NULL;
if((urlnode->flags&GETOUT_USEREMOTE) || if((urlnode->flags&GETOUT_USEREMOTE) ||
@ -3958,8 +3955,7 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
filep = curl_easy_escape(curl, filep, 0 /* use strlen */); filep = curl_easy_escape(curl, filep, 0 /* use strlen */);
if(filep) { if(filep) {
char *urlbuffer=(char *)malloc(strlen(url) + strlen(filep) + 3);
urlbuffer=(char *)malloc(strlen(url) + strlen(filep) + 3);
if(!urlbuffer) { if(!urlbuffer) {
helpf("out of memory\n"); helpf("out of memory\n");
return CURLE_OUT_OF_MEMORY; return CURLE_OUT_OF_MEMORY;
@ -4024,6 +4020,7 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
printf("%s%s\n", CURLseparator, url); printf("%s%s\n", CURLseparator, url);
} }
if (httpgetfields) { if (httpgetfields) {
char *urlbuffer;
/* Find out whether the url contains a file name */ /* Find out whether the url contains a file name */
const char *pc =strstr(url, "://"); const char *pc =strstr(url, "://");
char sep='?'; char sep='?';
@ -4372,6 +4369,7 @@ operate(struct Configurable *config, int argc, argv_item_t argv[])
RETRY_FTP, RETRY_FTP,
RETRY_LAST /* not used */ RETRY_LAST /* not used */
} retry = RETRY_NO; } retry = RETRY_NO;
long response;
if(CURLE_OPERATION_TIMEDOUT == res) if(CURLE_OPERATION_TIMEDOUT == res)
/* retry timeout always */ /* retry timeout always */
retry = RETRY_TIMEOUT; retry = RETRY_TIMEOUT;