From 0ede81dcc61844cecce8904fb4de24319afeb024 Mon Sep 17 00:00:00 2001
From: Carlos Henrique Lima Melara <charlesmelara@riseup.net>
Date: Thu, 5 Jun 2025 14:29:06 +0200
Subject: [PATCH] curl_path: make SFTP handle a path like /~ properly.

... without a trailing slash.

Fixes #17534
Closes #17542
---
 lib/vssh/curl_path.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/vssh/curl_path.c b/lib/vssh/curl_path.c
index 117d2e6009f6..474a5ecb8e27 100644
--- a/lib/vssh/curl_path.c
+++ b/lib/vssh/curl_path.c
@@ -84,6 +84,12 @@ CURLcode Curl_getworkingpath(struct Curl_easy *data,
         return CURLE_OUT_OF_MEMORY;
       }
     }
+    else {
+      if(curlx_dyn_add(&npath, "/")) {
+        free(working_path);
+        return CURLE_OUT_OF_MEMORY;
+      }
+    }
   }
 
   if(curlx_dyn_len(&npath)) {
