Skip to content

Commit 42575ac

Browse files
committed
Merge branch 'PHP-8.2' into PHP-8.3
* PHP-8.2: Fix GH-12974: Apache crashes on shutdown when using pg_pconnect()
2 parents 93951cf + 77ac1e8 commit 42575ac

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

NEWS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ PHP NEWS
3838
. Fixed bug GH-12936 (hash() function hangs endlessly if using sha512 on
3939
strings >= 4GiB). (nielsdos)
4040

41+
- ODBC:
42+
. Fix crash on Apache shutdown with persistent connections. (nielsdos)
43+
4144
- Opcache:
4245
. Fixed oss-fuzz #64727 (JIT undefined array key warning may overwrite DIM
4346
with NULL when DIM is the same var as result). (ilutov)
@@ -58,6 +61,8 @@ PHP NEWS
5861

5962
- PGSQL:
6063
. Fixed auto_reset_persistent handling and allow_persistent type. (David Carlier)
64+
. Fixed bug GH-12974 (Apache crashes on shutdown when using pg_pconnect()).
65+
(nielsdos)
6166

6267
- PHPDBG:
6368
. Fixed bug GH-12962 (Double free of init_file in phpdbg_prompt.c). (nielsdos)

ext/odbc/php_odbc.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,13 @@ static void _close_odbc_conn(zend_resource *rsrc)
168168
SQLFreeEnv(conn->henv);
169169
}
170170
efree(conn);
171-
ODBCG(num_links)--;
171+
/* See https://github.com/php/php-src/issues/12974 why we need to check the if */
172+
#ifdef ZTS
173+
if (odbc_module_entry.module_started)
174+
#endif
175+
{
176+
ODBCG(num_links)--;
177+
}
172178
}
173179
/* }}} */
174180

ext/pgsql/pgsql.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,14 @@ static void _close_pgsql_plink(zend_resource *rsrc)
315315
PQclear(res);
316316
}
317317
PQfinish(link);
318-
PGG(num_persistent)--;
319-
PGG(num_links)--;
318+
/* See https://github.com/php/php-src/issues/12974 why we need to check the if */
319+
#ifdef ZTS
320+
if (pgsql_module_entry.module_started)
321+
#endif
322+
{
323+
PGG(num_persistent)--;
324+
PGG(num_links)--;
325+
}
320326
rsrc->ptr = NULL;
321327
}
322328

0 commit comments

Comments
 (0)