From 0b34438ccc3fdcbdaa6226d2398df88cc7439603 Mon Sep 17 00:00:00 2001
From: xujing <xujing125@huawei.com>
Date: Thu, 24 Nov 2022 17:16:46 +0800
Subject: [PATCH 2/3] Fix file leak when src rpm in URL format is used for
 installation

%{_tmppath}/rpm-tmp.* is created by rpmMkTempFile() when src rpm in
URL format is used for installation, which is leaked.
---
 lib/rpminstall.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/lib/rpminstall.c b/lib/rpminstall.c
index eb68deb4d..b392cf1c3 100644
--- a/lib/rpminstall.c
+++ b/lib/rpminstall.c
@@ -673,8 +673,12 @@ exit:
 	}
     }
     if (eiu->sourceURL != NULL) {
-        for (i = 0; i < eiu->numSRPMS; i++)
+        for (i = 0; i < eiu->numSRPMS; i++) {
+	    if (eiu->sourceURL[i] == NULL) continue;
+	    if (eiu->pkgState[i] == 1)
+	        (void) unlink(eiu->sourceURL[i]);
 	    eiu->sourceURL[i] = _free(eiu->sourceURL[i]);
+	}
     }
     eiu->pkgState = _free(eiu->pkgState);
     eiu->pkgURL = _free(eiu->pkgURL);
-- 
2.33.0

