Skip to content

Commit c35be03

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix GH-7765: php_oci_cleanup_global_handles segfaults at second call
2 parents 206c521 + c435e67 commit c35be03

File tree

2 files changed

+18
-19
lines changed

2 files changed

+18
-19
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ PHP NEWS
2626
(devnexen)
2727
. Introduced MYSQLI_IS_MARIADB. (devnexen)
2828

29+
- OCI8:
30+
. Fixed bug GH-7765 (php_oci_cleanup_global_handles segfaults at second
31+
call). (cmb)
32+
2933
- Readline:
3034
. Fixed bug #81598 (Cannot input unicode characters in PHP 8 interactive
3135
shell). (Nikita)

ext/oci8/oci8.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -251,24 +251,6 @@ static void php_oci_init_global_handles(void)
251251
}
252252
/* }}} */
253253

254-
/* {{{ php_oci_cleanup_global_handles()
255-
*
256-
* Free global handles (if they were initialized before)
257-
*/
258-
static void php_oci_cleanup_global_handles(void)
259-
{
260-
if (OCI_G(err)) {
261-
PHP_OCI_CALL(OCIHandleFree, ((dvoid *) OCI_G(err), OCI_HTYPE_ERROR));
262-
OCI_G(err) = NULL;
263-
}
264-
265-
if (OCI_G(env)) {
266-
PHP_OCI_CALL(OCIHandleFree, ((dvoid *) OCI_G(env), OCI_HTYPE_ENV));
267-
OCI_G(env) = NULL;
268-
}
269-
}
270-
/* }}} */
271-
272254
/* {{{ PHP_GINIT_FUNCTION
273255
*
274256
* Zerofill globals during module init
@@ -282,10 +264,23 @@ static PHP_GINIT_FUNCTION(oci)
282264
/* {{{ PHP_GSHUTDOWN_FUNCTION
283265
*
284266
* Called for thread shutdown in ZTS, after module shutdown for non-ZTS
267+
* Free global handles (if they were initialized before)
285268
*/
286269
static PHP_GSHUTDOWN_FUNCTION(oci)
287270
{
288-
php_oci_cleanup_global_handles();
271+
if (oci_globals->err) {
272+
oci_globals->in_call = 1;
273+
OCIHandleFree((dvoid *) oci_globals->err, OCI_HTYPE_ERROR);
274+
oci_globals->in_call = 0;
275+
oci_globals->err = NULL;
276+
}
277+
278+
if (oci_globals->env) {
279+
oci_globals->in_call = 1;
280+
OCIHandleFree((dvoid *) oci_globals->env, OCI_HTYPE_ENV);
281+
oci_globals->in_call = 0;
282+
oci_globals->env = NULL;
283+
}
289284
}
290285
/* }}} */
291286

0 commit comments

Comments
 (0)