rpm/backport-Fix-sbp-leak-when-running-rpmbuild-with-quiet.patch

29 lines
982 B
Diff

From 6130bd31038ff17a03fcac6ec7e41ac744163dde Mon Sep 17 00:00:00 2001
From: xujing <xujing125@huawei.com>
Date: Sat, 26 Nov 2022 11:39:48 +0800
Subject: [PATCH 4/5] Fix *sbp leak when running rpmbuild with --quiet
When running rpmbuild with --quiet, the "*sbp" may be alloced many
times in buildSpec by calling doScript but only freed once. Fix it.
---
build/build.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/build/build.c b/build/build.c
index 9cd569b83..4437f6c9c 100644
--- a/build/build.c
+++ b/build/build.c
@@ -216,6 +216,9 @@ rpmRC doScript(rpmSpec spec, rpmBuildFlags what, const char *name,
buildCmd = rpmExpand(mCmd, " ", scriptName, NULL);
(void) poptParseArgvString(buildCmd, &argc, &argv);
+ if (sb_stdoutp && *sb_stdoutp)
+ *sb_stdoutp = freeStringBuf(*sb_stdoutp);
+
rpmlog(RPMLOG_NOTICE, _("Executing(%s): %s\n"), name, buildCmd);
if (rpmfcExec((ARGV_const_t)argv, NULL, sb_stdoutp, 1,
spec->buildSubdir)) {
--
2.27.0