Fix memory leak in download payload
The file stream associated with downloads without a filename is not being freed when downloading using the sandbox user. Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
571c13236f
commit
53b1db84ef
1 changed files with 6 additions and 4 deletions
|
@ -698,9 +698,9 @@ cleanup:
|
||||||
* only applies to FTP transfers. */
|
* only applies to FTP transfers. */
|
||||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
|
||||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, (char *)NULL);
|
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, (char *)NULL);
|
||||||
|
|
||||||
if(payload->localf != NULL) {
|
if(payload->localf != NULL) {
|
||||||
fclose(payload->localf);
|
fclose(payload->localf);
|
||||||
|
payload->localf = NULL;
|
||||||
utimes_long(payload->tempfile_name, remote_time);
|
utimes_long(payload->tempfile_name, remote_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -880,7 +880,6 @@ static int curl_download_internal(alpm_handle_t *handle,
|
||||||
p = NULL;
|
p = NULL;
|
||||||
err = -1;
|
err = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
int msgs_left = 0;
|
int msgs_left = 0;
|
||||||
CURLMsg *msg = curl_multi_info_read(curlm, &msgs_left);
|
CURLMsg *msg = curl_multi_info_read(curlm, &msgs_left);
|
||||||
|
@ -904,7 +903,6 @@ static int curl_download_internal(alpm_handle_t *handle,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = err ? -1 : updated ? 0 : 1;
|
int ret = err ? -1 : updated ? 0 : 1;
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "curl_download_internal return code is %d\n", ret);
|
_alpm_log(handle, ALPM_LOG_DEBUG, "curl_download_internal return code is %d\n", ret);
|
||||||
alpm_list_free(payloads);
|
alpm_list_free(payloads);
|
||||||
|
@ -1365,7 +1363,6 @@ int SYMEXPORT alpm_fetch_pkgurl(alpm_handle_t *handle, const alpm_list_t *urls,
|
||||||
_alpm_log(handle, ALPM_LOG_WARNING, _("failed to retrieve some files\n"));
|
_alpm_log(handle, ALPM_LOG_WARNING, _("failed to retrieve some files\n"));
|
||||||
event.type = ALPM_EVENT_PKG_RETRIEVE_FAILED;
|
event.type = ALPM_EVENT_PKG_RETRIEVE_FAILED;
|
||||||
EVENT(handle, &event);
|
EVENT(handle, &event);
|
||||||
|
|
||||||
GOTO_ERR(handle, ALPM_ERR_RETRIEVE, err);
|
GOTO_ERR(handle, ALPM_ERR_RETRIEVE, err);
|
||||||
} else {
|
} else {
|
||||||
event.type = ALPM_EVENT_PKG_RETRIEVE_DONE;
|
event.type = ALPM_EVENT_PKG_RETRIEVE_DONE;
|
||||||
|
@ -1412,6 +1409,11 @@ void _alpm_dload_payload_reset(struct dload_payload *payload)
|
||||||
{
|
{
|
||||||
ASSERT(payload, return);
|
ASSERT(payload, return);
|
||||||
|
|
||||||
|
if(payload->localf != NULL) {
|
||||||
|
fclose(payload->localf);
|
||||||
|
payload->localf = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
FREE(payload->remote_name);
|
FREE(payload->remote_name);
|
||||||
FREE(payload->tempfile_name);
|
FREE(payload->tempfile_name);
|
||||||
FREE(payload->destfile_name);
|
FREE(payload->destfile_name);
|
||||||
|
|
Loading…
Add table
Reference in a new issue