summaryrefslogtreecommitdiffstats
path: root/rpminfo.c
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2024-12-19 11:33:42 +0100
committerRemi Collet <remi@php.net>2024-12-19 11:33:42 +0100
commit571e91a150b12569676fe4db55bbd94d1f9a673c (patch)
treec1433a6e03e736f0cff725361e4d6946b39ec95b /rpminfo.c
parent5f8816e2d1eb233f505f6e34a770230b4dc22167 (diff)
close DB with macro change (can affect dbpath)
Diffstat (limited to 'rpminfo.c')
-rw-r--r--rpminfo.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/rpminfo.c b/rpminfo.c
index 17d08b4..ae8b8e7 100644
--- a/rpminfo.c
+++ b/rpminfo.c
@@ -70,6 +70,13 @@ static rpmdb rpminfo_getdb(void) {
return RPMINFO_G(db);
}
+static void rpminfo_closedb(void) {
+ if (RPMINFO_G(db)) {
+ rpmtsCloseDB(RPMINFO_G(ts));
+ RPMINFO_G(db) = NULL;
+ }
+}
+
static void rpm_header_to_zval(zval *return_value, Header h, zend_bool full)
{
HeaderIterator hi;
@@ -879,7 +886,7 @@ PHP_FUNCTION(rpmexpand)
RETURN_THROWS();
}
- (void)rpminfo_getts(); // read config files
+ (void)rpminfo_getts(); /* read config files */
result = rpmExpand(text, NULL);
RETVAL_STRING(result);
@@ -899,7 +906,7 @@ PHP_FUNCTION(rpmexpandnumeric)
RETURN_THROWS();
}
- (void)rpminfo_getts(); // read config files
+ (void)rpminfo_getts(); /* read config files */
result = rpmExpandNumeric(text);
@@ -919,7 +926,9 @@ PHP_FUNCTION(rpmdefine)
RETURN_THROWS();
}
- (void)rpminfo_getts(); // read config files
+ (void)rpminfo_getts(); /* read config files */
+
+ rpminfo_closedb(); /* Close the DB to allow path change */
result = rpmDefineMacro(NULL, macro, RMIL_GLOBAL);
@@ -999,10 +1008,8 @@ PHP_RINIT_FUNCTION(rpminfo)
PHP_RSHUTDOWN_FUNCTION(rpminfo)
{
if (RPMINFO_G(ts)) {
- if (RPMINFO_G(db)) {
- rpmtsCloseDB(RPMINFO_G(ts));
- RPMINFO_G(db) = NULL;
- }
+ rpminfo_closedb();
+
rpmtsFree(RPMINFO_G(ts));
RPMINFO_G(ts) = NULL;
}