diff options
author | Dan Fandrich <dan@coneharvesters.com> | 2007-04-11 00:25:41 +0000 |
---|---|---|
committer | Dan Fandrich <dan@coneharvesters.com> | 2007-04-11 00:25:41 +0000 |
commit | 47f044265e5e10a3fbcbfddb7849a816c102216e (patch) | |
tree | 71724b03eae0c53335b22cb649b34fef67be7324 /lib/ftp.c | |
parent | d46d995766a849dbbcfa2f362ccdbca24401a006 (diff) |
Fixed some out of memory handling issues.
Diffstat (limited to 'lib/ftp.c')
-rw-r--r-- | lib/ftp.c | 29 |
1 files changed, 13 insertions, 16 deletions
@@ -3647,7 +3647,6 @@ CURLcode Curl_ftp_disconnect(struct connectdata *conn) static CURLcode ftp_parse_url_path(struct connectdata *conn) { - CURLcode retcode = CURLE_OK; struct SessionHandle *data = conn->data; /* the ftp struct is already inited in ftp_connect() */ struct FTP *ftp = data->reqdata.proto.ftp; @@ -3720,6 +3719,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn) return CURLE_OUT_OF_MEMORY; } if (isBadFtpString(ftpc->dirs[ftpc->dirdepth])) { + free(ftpc->dirs[ftpc->dirdepth]); freedirs(conn); return CURLE_URL_MALFORMAT; } @@ -3729,20 +3729,17 @@ CURLcode ftp_parse_url_path(struct connectdata *conn) continue; } - if(!retcode) { - cur_pos = slash_pos + 1; /* jump to the rest of the string */ - if(++ftpc->dirdepth >= ftpc->diralloc) { - /* enlarge array */ - char *bigger; - ftpc->diralloc *= 2; /* double the size each time */ - bigger = realloc(ftpc->dirs, ftpc->diralloc * sizeof(ftpc->dirs[0])); - if(!bigger) { - ftpc->dirdepth--; - freedirs(conn); - return CURLE_OUT_OF_MEMORY; - } - ftpc->dirs = (char **)bigger; - } + cur_pos = slash_pos + 1; /* jump to the rest of the string */ + if(++ftpc->dirdepth >= ftpc->diralloc) { + /* enlarge array */ + char *bigger; + ftpc->diralloc *= 2; /* double the size each time */ + bigger = realloc(ftpc->dirs, ftpc->diralloc * sizeof(ftpc->dirs[0])); + if(!bigger) { + freedirs(conn); + return CURLE_OUT_OF_MEMORY; + } + ftpc->dirs = (char **)bigger; } } @@ -3790,7 +3787,7 @@ CURLcode ftp_parse_url_path(struct connectdata *conn) free(path); } - return retcode; + return CURLE_OK; } /* call this when the DO phase has completed */ |