From 515754faacf9dd33b94e6e5a17ca04d27d61f482 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Tue, 21 Aug 2007 23:29:10 -0400 Subject: Various valgrind mem leak fixes Signed-off-by: Dan McGee --- lib/libalpm/server.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lib/libalpm/server.c') diff --git a/lib/libalpm/server.c b/lib/libalpm/server.c index a1456a0a..6c74850e 100644 --- a/lib/libalpm/server.c +++ b/lib/libalpm/server.c @@ -244,6 +244,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, fclose(localf); } /* try the next server */ + downloadFreeURL(fileurl); continue; } else { _alpm_log(PM_LOG_DEBUG, "connected to %s successfully", fileurl->host); @@ -261,6 +262,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, if(dlf != NULL) { fclose(dlf); } + downloadFreeURL(fileurl); return(1); } } @@ -287,7 +289,8 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, if(dlf != NULL) { fclose(dlf); } - return -1; + downloadFreeURL(fileurl); + return(-1); } } @@ -302,6 +305,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, fn, downloadLastErrString); fclose(localf); fclose(dlf); + downloadFreeURL(fileurl); return(-1); } @@ -313,6 +317,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, realfile, strerror(errno)); fclose(localf); fclose(dlf); + downloadFreeURL(fileurl); return(-1); } } @@ -324,7 +329,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, if(handle->dlcb) handle->dlcb(pkgname, dltotal_bytes, ust.size); } - + downloadFreeURL(fileurl); fclose(localf); fclose(dlf); rename(output, realfile); @@ -339,7 +344,10 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, char cwd[PATH_MAX]; /* build the full download url */ - snprintf(url, PATH_MAX, "%s://%s%s", fileurl->scheme, fileurl->host, fileurl->doc); + snprintf(url, PATH_MAX, "%s://%s%s", fileurl->scheme, + fileurl->host, fileurl->doc); + /* we don't need this anymore */ + downloadFreeURL(fileurl); /* replace all occurrences of %o with fn.part */ strncpy(origCmd, handle->xfercommand, sizeof(origCmd)); @@ -387,12 +395,12 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath, } chdir(cwd); } - downloadFreeURL(fileurl); } if(alpm_list_count(complete) == alpm_list_count(files)) { done = 1; } + alpm_list_free(complete); } return(done ? 0 : -1); -- cgit v1.2.3-54-g00ecf