From ff5308a5af72681ae5eb91dafcc4049476ba5528 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Mon, 2 Dec 2002 07:18:24 +0000
Subject: [PATCH] if the PWD reply parser failed, we leaked memory

---
 lib/ftp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/ftp.c b/lib/ftp.c
index 387807942c..4f08a5348a 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -544,7 +544,7 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
        The directory name can contain any character; embedded double-quotes
        should be escaped by double-quotes (the "quote-doubling" convention).
     */
-    if('\"' == *ptr) {
+    if(dir && ('\"' == *ptr)) {
       /* it started good */
       ptr++;
       while(ptr && *ptr) {
@@ -570,6 +570,8 @@ CURLcode Curl_ftp_connect(struct connectdata *conn)
     }
     else {
       /* couldn't get the path */
+      free(dir);
+      infof(data, "Failed to figure out path\n");
     }
 
   }
-- 
GitLab