aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ftp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/ftp.c b/lib/ftp.c
index 65dfa8362..5016a6a80 100644
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -779,8 +779,10 @@ CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status)
dlen = strlen(path)-flen;
if(dlen) {
ftp->prevpath = malloc(dlen + 1);
- if(!ftp->prevpath)
+ if(!ftp->prevpath) {
+ free(path);
return CURLE_OUT_OF_MEMORY;
+ }
memcpy(ftp->prevpath, path, dlen);
ftp->prevpath[dlen]=0; /* terminate */
infof(data, "Remembering we are in dir %s\n", ftp->prevpath);