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.",
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;
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 */
/* 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);