diff options
Diffstat (limited to 'Utilities/cmcurl/lib/ftplistparser.c')
-rw-r--r-- | Utilities/cmcurl/lib/ftplistparser.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/Utilities/cmcurl/lib/ftplistparser.c b/Utilities/cmcurl/lib/ftplistparser.c index 262ac03..249fe09 100644 --- a/Utilities/cmcurl/lib/ftplistparser.c +++ b/Utilities/cmcurl/lib/ftplistparser.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -49,6 +49,7 @@ #include "ftplistparser.h" #include "curl_fnmatch.h" #include "curl_memory.h" +#include "multiif.h" /* The last #include file should be: */ #include "memdebug.h" @@ -184,10 +185,13 @@ struct ftp_parselist_data *Curl_ftp_parselist_data_alloc(void) } -void Curl_ftp_parselist_data_free(struct ftp_parselist_data **pl_data) +void Curl_ftp_parselist_data_free(struct ftp_parselist_data **parserp) { - free(*pl_data); - *pl_data = NULL; + struct ftp_parselist_data *parser = *parserp; + if(parser) + Curl_fileinfo_cleanup(parser->file_data); + free(parser); + *parserp = NULL; } @@ -269,9 +273,9 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn, { curl_fnmatch_callback compare; struct WildcardData *wc = &conn->data->wildcard; - struct ftp_wc_tmpdata *tmpdata = wc->tmp; + struct ftp_wc *ftpwc = wc->protdata; struct curl_llist *llist = &wc->filelist; - struct ftp_parselist_data *parser = tmpdata->parser; + struct ftp_parselist_data *parser = ftpwc->parser; bool add = TRUE; struct curl_fileinfo *finfo = &infop->info; @@ -294,6 +298,7 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn, compare = Curl_fnmatch; /* filter pattern-corresponding filenames */ + Curl_set_in_callback(conn->data, true); if(compare(conn->data->set.fnmatch_data, wc->pattern, finfo->filename) == 0) { /* discard symlink which is containing multiple " -> " */ @@ -305,15 +310,16 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn, else { add = FALSE; } + Curl_set_in_callback(conn->data, false); if(add) { Curl_llist_insert_next(llist, llist->tail, finfo, &infop->list); } else { - Curl_fileinfo_dtor(NULL, finfo); + Curl_fileinfo_cleanup(infop); } - tmpdata->parser->file_data = NULL; + ftpwc->parser->file_data = NULL; return CURLE_OK; } @@ -322,8 +328,8 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, { size_t bufflen = size*nmemb; struct connectdata *conn = (struct connectdata *)connptr; - struct ftp_wc_tmpdata *tmpdata = conn->data->wildcard.tmp; - struct ftp_parselist_data *parser = tmpdata->parser; + struct ftp_wc *ftpwc = conn->data->wildcard.protdata; + struct ftp_parselist_data *parser = ftpwc->parser; struct fileinfo *infop; struct curl_fileinfo *finfo; unsigned long i = 0; @@ -378,7 +384,7 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, finfo->b_data = tmp; } else { - Curl_fileinfo_dtor(NULL, parser->file_data); + Curl_fileinfo_cleanup(parser->file_data); parser->file_data = NULL; parser->error = CURLE_OUT_OF_MEMORY; goto fail; @@ -1000,12 +1006,13 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, i++; } + return retsize; fail: /* Clean up any allocated memory. */ if(parser->file_data) { - Curl_fileinfo_dtor(NULL, parser->file_data); + Curl_fileinfo_cleanup(parser->file_data); parser->file_data = NULL; } |