Avoid invoking unlink() with a NULL path if the URL isn't to a file and
we fail to create a temporary file.

Signed-off-by: Lukas Fleischer <[email protected]>
---
 lib/libalpm/dload.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index 5cbb6b4..050e719 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -195,6 +195,9 @@ static int curl_download_internal(struct dload_payload 
*payload,
        /* shortcut to our handle within the payload */
        alpm_handle_t *handle = payload->handle;
 
+       /* reset dload_interrupted early to avoid erroneous unlink() on cleanup 
*/
+       dload_interrupted = 0;
+
        if(!payload->filename) {
                payload->filename = get_filename(payload->fileurl);
        }
@@ -289,7 +292,6 @@ static int curl_download_internal(struct dload_payload 
*payload,
        sigaction(SIGPIPE, NULL, &sig_pipe[OLD]);
        sigaction(SIGPIPE, &sig_pipe[NEW], NULL);
 
-       dload_interrupted = 0;
        sig_int[NEW].sa_handler = &inthandler;
        sigemptyset(&sig_int[NEW].sa_mask);
        sig_int[NEW].sa_flags = 0;
-- 
1.7.6


Reply via email to