Skip to content

Commit dcf9d8f

Browse files
committed
Fix GH-18494: PDO OCI segfault in statement GC
This is the same issue that was fixed in 2ae897f, but now for OCI. Closes GH-18495.
1 parent fb3536f commit dcf9d8f

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ PHP NEWS
2525
. Fixed bug GH-18417 (Windows SHM reattachment fails when increasing
2626
memory_consumption or jit_buffer_size). (nielsdos)
2727

28+
- PDO_OCI:
29+
. Fixed bug GH-18494 (PDO OCI segfault in statement GC). (nielsdos)
30+
2831
- SPL:
2932
. Fixed bug GH-18421 (Integer overflow with large numbers in LimitIterator).
3033
(nielsdos)

ext/pdo_oci/oci_statement.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,21 @@ static int oci_stmt_dtor(pdo_stmt_t *stmt) /* {{{ */
9898
S->einfo.errmsg = NULL;
9999
}
100100

101+
/* TODO: There's php_pdo_stmt_valid_db_obj_handle in PHP-8.5-dev that does these checks. */
102+
bool server_obj_usable = !Z_ISUNDEF(stmt->database_object_handle)
103+
&& IS_OBJ_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE(stmt->database_object_handle)])
104+
&& !(OBJ_FLAGS(Z_OBJ(stmt->database_object_handle)) & IS_OBJ_FREE_CALLED);
105+
101106
if (S->cols) {
102107
for (i = 0; i < stmt->column_count; i++) {
103108
if (S->cols[i].data) {
104109
switch (S->cols[i].dtype) {
105110
case SQLT_BLOB:
106111
case SQLT_CLOB:
107-
OCI_TEMPLOB_CLOSE(S->H->env, S->H->svc, S->H->err,
108-
(OCILobLocator *) S->cols[i].data);
112+
if (server_obj_usable) {
113+
OCI_TEMPLOB_CLOSE(S->H->env, S->H->svc, S->H->err,
114+
(OCILobLocator *) S->cols[i].data);
115+
}
109116
OCIDescriptorFree(S->cols[i].data, OCI_DTYPE_LOB);
110117
break;
111118
default:

0 commit comments

Comments
 (0)