Fixed curl_slist_append handling of out of memory conditions on the

easycode list (discovered by runtests' torture test).
This commit is contained in:
Dan Fandrich 2007-04-04 20:27:47 +00:00
parent 09dd2d3856
commit fd016fb3ee

View File

@ -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);