diff --git a/src/tool_main.c b/src/tool_main.c
index 955e4795f507d4f465dd64a10411c3b15e1376e2..1e9156aca31032f0ac262429c8a607739f32dea4 100644
--- a/src/tool_main.c
+++ b/src/tool_main.c
@@ -154,13 +154,18 @@ static CURLcode main_init(struct GlobalConfig *config)
         else {
           helpf(stderr, "error initializing curl easy handle\n");
           result = CURLE_FAILED_INIT;
+          free(config->first);
         }
       }
-      else
+      else {
         helpf(stderr, "error retrieving curl library information\n");
+        free(config->first);
+      }
     }
-    else
+    else {
       helpf(stderr, "error initializing curl library\n");
+      free(config->first);
+    }
   }
   else {
     helpf(stderr, "error initializing curl\n");