Skip to content

Commit 7be5da4

Browse files
committed
Fix php/php-src#18494: PDO OCI segfault in statement GC
This is the same issue that was fixed in 2ae897fff7af3a794a31a8aeeeeb4f21f6a41393, but now for OCI. Fixed at php-src on 8.3 in php/php-src#18495
1 parent d480a23 commit 7be5da4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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)