php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login

Patch bug79270.patch for PDO ODBC Bug #79270

Patch version 2020-11-05 11:47 UTC

Return to Bug #79270 | Download this patch
Patch Revisions:

Developer: cmb@php.net

 ext/pdo_odbc/odbc_stmt.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c
index 08a08b2a54..1a06e903cc 100644
--- a/ext/pdo_odbc/odbc_stmt.c
+++ b/ext/pdo_odbc/odbc_stmt.c
@@ -140,12 +140,15 @@ static void free_cols(pdo_stmt_t *stmt, pdo_odbc_stmt *S)
 static int odbc_stmt_dtor(pdo_stmt_t *stmt)
 {
 	pdo_odbc_stmt *S = (pdo_odbc_stmt*)stmt->driver_data;
+	pdo_odbc_db_handle *H = S->H;
 
 	if (S->stmt != SQL_NULL_HANDLE) {
-		if (stmt->executed) {
-			SQLCloseCursor(S->stmt);
+		if (H->env != NULL) {
+			if (stmt->executed) {
+				SQLCloseCursor(S->stmt);
+			}
+			SQLFreeHandle(SQL_HANDLE_STMT, S->stmt);
 		}
-		SQLFreeHandle(SQL_HANDLE_STMT, S->stmt);
 		S->stmt = SQL_NULL_HANDLE;
 	}
 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 14 07:01:32 2024 UTC