]> granicus.if.org Git - curl/commitdiff
tool_operate.c: OOM handling fix
authorYang Tse <yangsita@gmail.com>
Sat, 22 Oct 2011 12:46:49 +0000 (14:46 +0200)
committerYang Tse <yangsita@gmail.com>
Sat, 22 Oct 2011 12:49:02 +0000 (14:49 +0200)
Move curl_easy_perform source code geneartion out of curl_easy_perform's loop
for proper OOM handling and source code geneartion.

src/tool_operate.c

index 65f4b60b8533a94348187b2671128719d5f97139..7ab815f8386c27240b7e9856873b3facb77cf1a0 100644 (file)
@@ -1208,12 +1208,13 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
         retry_sleep = retry_sleep_default; /* ms */
         retrystart = tvnow();
 
+        if(!curl_slist_append(easysrc, "ret = curl_easy_perform(hnd);")) {
+          res = CURLE_OUT_OF_MEMORY;
+          goto show_error;
+        }
+
         for(;;) {
           res = curl_easy_perform(curl);
-          if(!curl_slist_append(easysrc, "ret = curl_easy_perform(hnd);")) {
-            res = CURLE_OUT_OF_MEMORY;
-            goto show_error;
-          }
 
           if(config->content_disposition && outs.stream && !config->mute &&
              outs.filename)