]> granicus.if.org Git - php/commitdiff
MFH(r-1.91) Fix Bug #25294 LIST/NLST can cause segfault because ftp->data not cleaned...
authorSara Golemon <pollita@php.net>
Tue, 9 Sep 2003 21:15:20 +0000 (21:15 +0000)
committerSara Golemon <pollita@php.net>
Tue, 9 Sep 2003 21:15:20 +0000 (21:15 +0000)
ext/ftp/ftp.c

index 1d20ec2fc3134ce854a9442da2f269c6d4e0243f..01710ec6565a2749181ba99216e61f653d561fec 100644 (file)
@@ -421,9 +421,10 @@ ftp_chdir(ftpbuf_t *ftp, const char *dir)
 {
        if (ftp == NULL)
                return 0;
-       if (ftp->pwd)
+       if (ftp->pwd) {
                efree(ftp->pwd);
-       ftp->pwd = NULL;
+               ftp->pwd = NULL;
+       }
 
        if (!ftp_putcmd(ftp, "CWD", dir))
                return 0;
@@ -442,9 +443,10 @@ ftp_cdup(ftpbuf_t *ftp)
        if (ftp == NULL)
                return 0;
 
-       if (ftp->pwd)
+       if (ftp->pwd) {
                efree(ftp->pwd);
-       ftp->pwd = NULL;
+               ftp->pwd = NULL;
+       }
 
        if (!ftp_putcmd(ftp, "CDUP", NULL))
                return 0;
@@ -1535,8 +1537,7 @@ ftp_genlist(ftpbuf_t *ftp, const char *cmd, const char *path TSRMLS_DC)
 
        return ret;
 bail:
-       if (data)
-               ftp->data = data_close(ftp, data);
+       ftp->data = data_close(ftp, data);
        fclose(tmpfp);
        if (ret)
                efree(ret);