summaryrefslogtreecommitdiffstats
path: root/rpminfo.c
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2018-01-26 11:14:33 +0100
committerRemi Collet <remi@remirepo.net>2018-01-26 11:14:33 +0100
commitc4521c64e148640fa9ad840e9ea3cb45293204dd (patch)
treef511667363552283ab2c6c8db6a04b92e3a4a014 /rpminfo.c
parent2e773e19b01012e45182b725cae71efeb1449415 (diff)
fix segfault in ZTS mode
Diffstat (limited to 'rpminfo.c')
-rw-r--r--rpminfo.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/rpminfo.c b/rpminfo.c
index eeb1f6e..169ef96 100644
--- a/rpminfo.c
+++ b/rpminfo.c
@@ -42,13 +42,6 @@ static rpmts rpminfo_getts(rpmVSFlags flags) {
return RPMINFO_G(ts);
}
-static void rpminfo_freets(void) {
- if (RPMINFO_G(ts)) {
- rpmtsFree(RPMINFO_G(ts));
- RPMINFO_G(ts) = NULL;
- }
-}
-
ZEND_BEGIN_ARG_INFO_EX(arginfo_rpminfo, 0, 0, 1)
ZEND_ARG_INFO(0, path)
ZEND_ARG_INFO(0, full)
@@ -170,6 +163,18 @@ PHP_FUNCTION(rpmvercmp)
}
/* }}} */
+/* Remove if there's nothing to do at request start */
+/* {{{ PHP_RINIT_FUNCTION
+ */
+PHP_RINIT_FUNCTION(rpminfo)
+{
+#if defined(COMPILE_DL_RPMINFO) && defined(ZTS)
+ ZEND_TSRMLS_CACHE_UPDATE();
+#endif
+ return SUCCESS;
+}
+/* }}} */
+
/* {{{ PHP_MINFO_FUNCTION
*/
PHP_MINFO_FUNCTION(rpminfo)
@@ -193,7 +198,6 @@ static PHP_GINIT_FUNCTION(rpminfo) /* {{{ */
#if defined(COMPILE_DL_SESSION) && defined(ZTS)
ZEND_TSRMLS_CACHE_UPDATE();
#endif
-
rpminfo_globals->ts = NULL;
}
/* }}} */
@@ -202,7 +206,10 @@ static PHP_GINIT_FUNCTION(rpminfo) /* {{{ */
*/
PHP_GSHUTDOWN_FUNCTION(rpminfo)
{
- rpminfo_freets();
+ if (rpminfo_globals->ts) {
+ rpmtsFree(rpminfo_globals->ts);
+ rpminfo_globals->ts = NULL;
+ }
}
/* }}} */
@@ -227,7 +234,7 @@ zend_module_entry rpminfo_module_entry = {
rpminfo_functions,
NULL,
NULL,
- NULL,
+ PHP_RINIT(rpminfo),
NULL,
PHP_MINFO(rpminfo),
PHP_RPMINFO_VERSION,