Skip to content

Fix GH-18494: PDO OCI segfault in statement GC #18495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions ext/pdo_oci/oci_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,21 @@ static int oci_stmt_dtor(pdo_stmt_t *stmt) /* {{{ */
S->einfo.errmsg = NULL;
}

/* TODO: There's php_pdo_stmt_valid_db_obj_handle in PHP-8.5-dev that does these checks. */
bool server_obj_usable = !Z_ISUNDEF(stmt->database_object_handle)
&& IS_OBJ_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE(stmt->database_object_handle)])
&& !(OBJ_FLAGS(Z_OBJ(stmt->database_object_handle)) & IS_OBJ_FREE_CALLED);

if (S->cols) {
for (i = 0; i < stmt->column_count; i++) {
if (S->cols[i].data) {
switch (S->cols[i].dtype) {
case SQLT_BLOB:
case SQLT_CLOB:
OCI_TEMPLOB_CLOSE(S->H->env, S->H->svc, S->H->err,
(OCILobLocator *) S->cols[i].data);
if (server_obj_usable) {
OCI_TEMPLOB_CLOSE(S->H->env, S->H->svc, S->H->err,
(OCILobLocator *) S->cols[i].data);
}
OCIDescriptorFree(S->cols[i].data, OCI_DTYPE_LOB);
break;
default:
Expand Down
Loading