Skip to content

Commit 556def7

Browse files
authored
Fix crash in PDO_ODBC statement dtor (#17586)
Port of 2ae897f to PDO_ODBC.
1 parent 1a4810a commit 556def7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ext/pdo_odbc/odbc_stmt.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ static int odbc_stmt_dtor(pdo_stmt_t *stmt)
136136
{
137137
pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data;
138138

139-
if (S->stmt != SQL_NULL_HANDLE) {
139+
// TODO: Factor this out; pg/mysql/firebird do the same thing
140+
bool server_obj_usable = !Z_ISUNDEF(stmt->database_object_handle)
141+
&& IS_OBJ_VALID(EG(objects_store).object_buckets[Z_OBJ_HANDLE(stmt->database_object_handle)])
142+
&& !(OBJ_FLAGS(Z_OBJ(stmt->database_object_handle)) & IS_OBJ_FREE_CALLED);
143+
if (S->stmt != SQL_NULL_HANDLE && server_obj_usable) {
140144
if (stmt->executed) {
141145
SQLCloseCursor(S->stmt);
142146
}

0 commit comments

Comments
 (0)