aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c20
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);