diff options
author | Dan Fandrich <dan@coneharvesters.com> | 2007-04-04 20:27:47 +0000 |
---|---|---|
committer | Dan Fandrich <dan@coneharvesters.com> | 2007-04-04 20:27:47 +0000 |
commit | fd016fb3ee75aa1e87b1c41ae7b05e163f65b351 (patch) | |
tree | eec6d708c09b87c8938036762b6c76a45d25adf7 /src | |
parent | 09dd2d3856c9d5af18bdfc89ced5228d0c1e6267 (diff) |
Fixed curl_slist_append handling of out of memory conditions on the
easycode list (discovered by runtests' torture test).
Diffstat (limited to 'src')
-rw-r--r-- | src/main.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c index f9a13e0af..777b024a5 100644 --- a/src/main.c +++ b/src/main.c @@ -3396,14 +3396,15 @@ CURLcode _my_setopt(CURL *curl, const char *name, CURLoption tag, ...) remark?"/* ":"", name, value, remark?" [REMARK] */":""); - easycode = curl_slist_append(easycode, bufp); + if (!curl_slist_append(easycode, bufp)) + ret = CURLE_OUT_OF_MEMORY; curl_free(bufp); va_end(arg); return ret; } -static const char *srchead[]={ +static const char * const srchead[]={ "/********* Sample code generated by the curl command line tool **********", " * Lines with [REMARK] below might need to be modified to make this code ", " * usable. Add appropriate error code checking where appropriate.", @@ -3699,7 +3700,14 @@ operate(struct Configurable *config, int argc, char *argv[]) clean_getout(config); return CURLE_FAILED_INIT; } + + /* This is the first entry added to easycode and it initializes the slist */ easycode = curl_slist_append(easycode, "CURL *hnd = curl_easy_init();"); + if(!easycode) { + clean_getout(config); + res = CURLE_OUT_OF_MEMORY; + goto quit_curl; + } if (config->list_engines) { struct curl_slist *engines = NULL; @@ -4327,8 +4335,10 @@ operate(struct Configurable *config, int argc, char *argv[]) do { res = curl_easy_perform(curl); - easycode = curl_slist_append(easycode, - "ret = curl_easy_perform(hnd);"); + if (!curl_slist_append(easycode, "ret = curl_easy_perform(hnd);")) { + res = CURLE_OUT_OF_MEMORY; + break; + } /* if retry-max-time is non-zero, make sure we haven't exceeded the time */ @@ -4569,7 +4579,7 @@ quit_curl: /* cleanup the curl handle! */ curl_easy_cleanup(curl); - easycode = curl_slist_append(easycode, "curl_easy_cleanup(hnd);"); + curl_slist_append(easycode, "curl_easy_cleanup(hnd);"); if(config->headerfile && !headerfilep && heads.stream) fclose(heads.stream); |