Loading lib/fileinfo.c +5 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 2010 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2010 - 2017, 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 Loading Loading @@ -33,11 +33,14 @@ struct fileinfo *Curl_fileinfo_alloc(void) return calloc(1, sizeof(struct fileinfo)); } void Curl_fileinfo_cleanup(struct fileinfo *finfo) void Curl_fileinfo_dtor(void *user, void *element) { struct fileinfo *finfo = element; (void) user; if(!finfo) return; Curl_safefree(finfo->info.b_data); free(finfo); } lib/fileinfo.h +3 −2 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 2010 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2010, 2017, 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 Loading @@ -31,6 +31,7 @@ struct fileinfo { }; struct fileinfo *Curl_fileinfo_alloc(void); void Curl_fileinfo_cleanup(struct fileinfo *finfo); void Curl_fileinfo_dtor(void *, void *); #endif /* HEADER_CURL_FILEINFO_H */ lib/ftp.c +16 −21 Original line number Diff line number Diff line Loading @@ -3699,7 +3699,7 @@ static CURLcode init_wc_data(struct connectdata *conn) char *path = conn->data->state.path; struct WildcardData *wildcard = &(conn->data->wildcard); CURLcode result = CURLE_OK; struct ftp_wc *ftpwc = NULL; struct ftp_wc *ftpwc; last_slash = strrchr(conn->data->state.path, '/'); if(last_slash) { Loading Loading @@ -3734,15 +3734,16 @@ static CURLcode init_wc_data(struct connectdata *conn) /* allocate ftp protocol specific wildcard data */ ftpwc = calloc(1, sizeof(struct ftp_wc)); if(!ftpwc) { result = CURLE_OUT_OF_MEMORY; goto fail; Curl_safefree(wildcard->pattern); return CURLE_OUT_OF_MEMORY; } /* INITIALIZE parselist structure */ ftpwc->parser = Curl_ftp_parselist_data_alloc(); if(!ftpwc->parser) { result = CURLE_OUT_OF_MEMORY; goto fail; Curl_safefree(wildcard->pattern); free(ftpwc); return CURLE_OUT_OF_MEMORY; } wildcard->protdata = ftpwc; /* put it to the WildcardData tmp pointer */ Loading @@ -3755,13 +3756,20 @@ static CURLcode init_wc_data(struct connectdata *conn) /* try to parse ftp url */ result = ftp_parse_url_path(conn); if(result) { goto fail; Curl_safefree(wildcard->pattern); wildcard->dtor(wildcard->protdata); wildcard->dtor = ZERO_NULL; wildcard->protdata = NULL; return result; } wildcard->path = strdup(conn->data->state.path); if(!wildcard->path) { result = CURLE_OUT_OF_MEMORY; goto fail; Curl_safefree(wildcard->pattern); wildcard->dtor(wildcard->protdata); wildcard->dtor = ZERO_NULL; wildcard->protdata = NULL; return CURLE_OUT_OF_MEMORY; } /* backup old write_function */ Loading @@ -3775,17 +3783,6 @@ static CURLcode init_wc_data(struct connectdata *conn) infof(conn->data, "Wildcard - Parsing started\n"); return CURLE_OK; fail: if(ftpwc) { Curl_ftp_parselist_data_free(&ftpwc->parser); free(ftpwc); } Curl_safefree(wildcard->pattern); wildcard->dtor(wildcard->protdata); wildcard->dtor = ZERO_NULL; wildcard->protdata = NULL; return result; } /* This is called recursively */ Loading Loading @@ -3906,8 +3903,6 @@ static CURLcode wc_statemach(struct connectdata *conn) case CURLWC_DONE: case CURLWC_ERROR: case CURLWC_CLEAR: if(wildcard->dtor) wildcard->dtor(wildcard->protdata); break; } Loading lib/ftplistparser.c +7 −11 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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 Loading Loading @@ -185,13 +185,10 @@ struct ftp_parselist_data *Curl_ftp_parselist_data_alloc(void) } void Curl_ftp_parselist_data_free(struct ftp_parselist_data **parserp) void Curl_ftp_parselist_data_free(struct ftp_parselist_data **pl_data) { struct ftp_parselist_data *parser = *parserp; if(parser) Curl_fileinfo_cleanup(parser->file_data); free(parser); *parserp = NULL; free(*pl_data); *pl_data = NULL; } Loading Loading @@ -316,7 +313,7 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn, Curl_llist_insert_next(llist, llist->tail, finfo, &infop->list); } else { Curl_fileinfo_cleanup(infop); Curl_fileinfo_dtor(NULL, finfo); } ftpwc->parser->file_data = NULL; Loading Loading @@ -384,7 +381,7 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, finfo->b_data = tmp; } else { Curl_fileinfo_cleanup(parser->file_data); Curl_fileinfo_dtor(NULL, parser->file_data); parser->file_data = NULL; parser->error = CURLE_OUT_OF_MEMORY; goto fail; Loading Loading @@ -1006,13 +1003,12 @@ 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_cleanup(parser->file_data); Curl_fileinfo_dtor(NULL, parser->file_data); parser->file_data = NULL; } Loading lib/wildcard.c +1 −7 Original line number Diff line number Diff line Loading @@ -30,15 +30,9 @@ #include "curl_memory.h" #include "memdebug.h" static void fileinfo_dtor(void *user, void *element) { (void)user; Curl_fileinfo_cleanup(element); } CURLcode Curl_wildcard_init(struct WildcardData *wc) { Curl_llist_init(&wc->filelist, fileinfo_dtor); Curl_llist_init(&wc->filelist, Curl_fileinfo_dtor); wc->state = CURLWC_INIT; return CURLE_OK; Loading Loading
lib/fileinfo.c +5 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 2010 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2010 - 2017, 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 Loading Loading @@ -33,11 +33,14 @@ struct fileinfo *Curl_fileinfo_alloc(void) return calloc(1, sizeof(struct fileinfo)); } void Curl_fileinfo_cleanup(struct fileinfo *finfo) void Curl_fileinfo_dtor(void *user, void *element) { struct fileinfo *finfo = element; (void) user; if(!finfo) return; Curl_safefree(finfo->info.b_data); free(finfo); }
lib/fileinfo.h +3 −2 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 2010 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2010, 2017, 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 Loading @@ -31,6 +31,7 @@ struct fileinfo { }; struct fileinfo *Curl_fileinfo_alloc(void); void Curl_fileinfo_cleanup(struct fileinfo *finfo); void Curl_fileinfo_dtor(void *, void *); #endif /* HEADER_CURL_FILEINFO_H */
lib/ftp.c +16 −21 Original line number Diff line number Diff line Loading @@ -3699,7 +3699,7 @@ static CURLcode init_wc_data(struct connectdata *conn) char *path = conn->data->state.path; struct WildcardData *wildcard = &(conn->data->wildcard); CURLcode result = CURLE_OK; struct ftp_wc *ftpwc = NULL; struct ftp_wc *ftpwc; last_slash = strrchr(conn->data->state.path, '/'); if(last_slash) { Loading Loading @@ -3734,15 +3734,16 @@ static CURLcode init_wc_data(struct connectdata *conn) /* allocate ftp protocol specific wildcard data */ ftpwc = calloc(1, sizeof(struct ftp_wc)); if(!ftpwc) { result = CURLE_OUT_OF_MEMORY; goto fail; Curl_safefree(wildcard->pattern); return CURLE_OUT_OF_MEMORY; } /* INITIALIZE parselist structure */ ftpwc->parser = Curl_ftp_parselist_data_alloc(); if(!ftpwc->parser) { result = CURLE_OUT_OF_MEMORY; goto fail; Curl_safefree(wildcard->pattern); free(ftpwc); return CURLE_OUT_OF_MEMORY; } wildcard->protdata = ftpwc; /* put it to the WildcardData tmp pointer */ Loading @@ -3755,13 +3756,20 @@ static CURLcode init_wc_data(struct connectdata *conn) /* try to parse ftp url */ result = ftp_parse_url_path(conn); if(result) { goto fail; Curl_safefree(wildcard->pattern); wildcard->dtor(wildcard->protdata); wildcard->dtor = ZERO_NULL; wildcard->protdata = NULL; return result; } wildcard->path = strdup(conn->data->state.path); if(!wildcard->path) { result = CURLE_OUT_OF_MEMORY; goto fail; Curl_safefree(wildcard->pattern); wildcard->dtor(wildcard->protdata); wildcard->dtor = ZERO_NULL; wildcard->protdata = NULL; return CURLE_OUT_OF_MEMORY; } /* backup old write_function */ Loading @@ -3775,17 +3783,6 @@ static CURLcode init_wc_data(struct connectdata *conn) infof(conn->data, "Wildcard - Parsing started\n"); return CURLE_OK; fail: if(ftpwc) { Curl_ftp_parselist_data_free(&ftpwc->parser); free(ftpwc); } Curl_safefree(wildcard->pattern); wildcard->dtor(wildcard->protdata); wildcard->dtor = ZERO_NULL; wildcard->protdata = NULL; return result; } /* This is called recursively */ Loading Loading @@ -3906,8 +3903,6 @@ static CURLcode wc_statemach(struct connectdata *conn) case CURLWC_DONE: case CURLWC_ERROR: case CURLWC_CLEAR: if(wildcard->dtor) wildcard->dtor(wildcard->protdata); break; } Loading
lib/ftplistparser.c +7 −11 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2017, 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 Loading Loading @@ -185,13 +185,10 @@ struct ftp_parselist_data *Curl_ftp_parselist_data_alloc(void) } void Curl_ftp_parselist_data_free(struct ftp_parselist_data **parserp) void Curl_ftp_parselist_data_free(struct ftp_parselist_data **pl_data) { struct ftp_parselist_data *parser = *parserp; if(parser) Curl_fileinfo_cleanup(parser->file_data); free(parser); *parserp = NULL; free(*pl_data); *pl_data = NULL; } Loading Loading @@ -316,7 +313,7 @@ static CURLcode ftp_pl_insert_finfo(struct connectdata *conn, Curl_llist_insert_next(llist, llist->tail, finfo, &infop->list); } else { Curl_fileinfo_cleanup(infop); Curl_fileinfo_dtor(NULL, finfo); } ftpwc->parser->file_data = NULL; Loading Loading @@ -384,7 +381,7 @@ size_t Curl_ftp_parselist(char *buffer, size_t size, size_t nmemb, finfo->b_data = tmp; } else { Curl_fileinfo_cleanup(parser->file_data); Curl_fileinfo_dtor(NULL, parser->file_data); parser->file_data = NULL; parser->error = CURLE_OUT_OF_MEMORY; goto fail; Loading Loading @@ -1006,13 +1003,12 @@ 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_cleanup(parser->file_data); Curl_fileinfo_dtor(NULL, parser->file_data); parser->file_data = NULL; } Loading
lib/wildcard.c +1 −7 Original line number Diff line number Diff line Loading @@ -30,15 +30,9 @@ #include "curl_memory.h" #include "memdebug.h" static void fileinfo_dtor(void *user, void *element) { (void)user; Curl_fileinfo_cleanup(element); } CURLcode Curl_wildcard_init(struct WildcardData *wc) { Curl_llist_init(&wc->filelist, fileinfo_dtor); Curl_llist_init(&wc->filelist, Curl_fileinfo_dtor); wc->state = CURLWC_INIT; return CURLE_OK; Loading