]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ftp: refactor a piece of code by merging the repeated part
authorx2018 <xkernel.wang@foxmail.com>
Sat, 8 Nov 2025 17:54:51 +0000 (01:54 +0800)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 9 Nov 2025 10:39:56 +0000 (11:39 +0100)
Closes #19411

lib/ftp.c

index 819fab462b93059c8688a7af06f68f8e538f4ca7..dd70c2a5ce8c1cf8e452474e30ffe7b2ff3d60f3 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -2744,16 +2744,6 @@ static CURLcode ftp_pwd_resp(struct Curl_easy *data,
           free(dir);
           return result;
         }
-        free(ftpc->entrypath);
-        ftpc->entrypath = dir; /* remember this */
-        infof(data, "Entry path is '%s'", ftpc->entrypath);
-        /* also save it where getinfo can access it: */
-        free(data->state.most_recent_ftp_entrypath);
-        data->state.most_recent_ftp_entrypath = strdup(ftpc->entrypath);
-        if(!data->state.most_recent_ftp_entrypath)
-          return CURLE_OUT_OF_MEMORY;
-        ftp_state(data, ftpc, FTP_SYST);
-        return result;
       }
 
       free(ftpc->entrypath);
@@ -2764,6 +2754,11 @@ static CURLcode ftp_pwd_resp(struct Curl_easy *data,
       data->state.most_recent_ftp_entrypath = strdup(ftpc->entrypath);
       if(!data->state.most_recent_ftp_entrypath)
         return CURLE_OUT_OF_MEMORY;
+
+      if(!ftpc->server_os && dir[0] != '/') {
+        ftp_state(data, ftpc, FTP_SYST);
+        return CURLE_OK;
+      }
     }
     else {
       /* could not get the path */