mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
Don't free too much in freedirs() if realloc() fails.
This commit is contained in:
parent
e36fb1ecda
commit
82b93e4945
@ -2754,10 +2754,9 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
|||||||
|
|
||||||
ftp->dirdepth = 0;
|
ftp->dirdepth = 0;
|
||||||
ftp->diralloc = 5; /* default dir depth to allocate */
|
ftp->diralloc = 5; /* default dir depth to allocate */
|
||||||
ftp->dirs = (char **)malloc(ftp->diralloc * sizeof(ftp->dirs[0]));
|
ftp->dirs = (char **)calloc(ftp->diralloc, sizeof(ftp->dirs[0]));
|
||||||
if(!ftp->dirs)
|
if(!ftp->dirs)
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
ftp->dirs[0] = NULL; /* to start with */
|
|
||||||
|
|
||||||
/* parse the URL path into separate path components */
|
/* parse the URL path into separate path components */
|
||||||
while((slash_pos=strchr(cur_pos, '/'))) {
|
while((slash_pos=strchr(cur_pos, '/'))) {
|
||||||
@ -2795,6 +2794,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn)
|
|||||||
ftp->diralloc *= 2; /* double the size each time */
|
ftp->diralloc *= 2; /* double the size each time */
|
||||||
bigger = realloc(ftp->dirs, ftp->diralloc * sizeof(ftp->dirs[0]));
|
bigger = realloc(ftp->dirs, ftp->diralloc * sizeof(ftp->dirs[0]));
|
||||||
if(!bigger) {
|
if(!bigger) {
|
||||||
|
ftp->dirdepth--;
|
||||||
freedirs(ftp);
|
freedirs(ftp);
|
||||||
return CURLE_OUT_OF_MEMORY;
|
return CURLE_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user