Commit e3d342df authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

avoid an extra malloc

parent ff54a74b
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -778,19 +778,16 @@ CURLcode Curl_ftp_done(struct connectdata *conn, CURLcode status)
  flen = ftp->file?strlen(ftp->file):0; /* file is "raw" already */
  dlen = strlen(path)-flen;
  if(dlen) {
    ftp->prevpath = malloc(dlen + 1);
    if(!ftp->prevpath) {
      free(path);
      return CURLE_OUT_OF_MEMORY;
    }
    memcpy(ftp->prevpath, path, dlen);
    ftp->prevpath = path;
    if(flen)
      /* if 'path' is not the whole string */
      ftp->prevpath[dlen]=0; /* terminate */
    infof(data, "Remembering we are in dir %s\n", ftp->prevpath);
  }
  else
  else {
    ftp->prevpath = NULL; /* no path */
    free(path);

  }
  /* free the dir tree and file parts */
  freedirs(ftp);