]> granicus.if.org Git - php/commitdiff
MFH
authorMatteo Beccati <mbeccati@php.net>
Tue, 12 May 2009 21:57:42 +0000 (21:57 +0000)
committerMatteo Beccati <mbeccati@php.net>
Tue, 12 May 2009 21:57:42 +0000 (21:57 +0000)
- Backported fix for #44301
- Fixed bug #48070
# The backport was required to also fix #48070

NEWS
ext/pdo_oci/oci_driver.c
ext/pdo_oci/oci_statement.c
ext/pdo_oci/tests/bug44301.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index e930b6808f728a18a85754bc30834a5ed2c9af0c..bd5732d25d69c41d2bacba9724a8dd5b8ea20cad 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,8 @@ PHP                                                                        NEWS
   bindto). (Ilia)
 - Fixed bug #48132 (configure check for curl ssl support fails with
   --disable-rpath). (Jani)
+- Fixed bug #48070 (PDO_OCI: Segfault when using persistent connection).
+  (Pierre, Matteo)
 - Fixed bug #48058 (Year formatter goes wrong with out-of-int range). (Derick)
 - Fixed bug #48038 (odbc_execute changes variables used to form params array).
   (Felipe)
index 18afb17a41e526ed6ca1eab56500c09a2038a202..a57d5a61ea7e2b0116ea26243f0040bd1b0acf02 100755 (executable)
@@ -70,15 +70,13 @@ ub4 _oci_error(OCIError *err, pdo_dbh_t *dbh, pdo_stmt_t *stmt, char *what, swor
                S = (pdo_oci_stmt*)stmt->driver_data;
                einfo = &S->einfo;
                pdo_err = &stmt->error_code;
-               if (einfo->errmsg) {
-                       efree(einfo->errmsg);
-               }
        }
        else {
                einfo = &H->einfo;
-               if (einfo->errmsg) {
-                       pefree(einfo->errmsg, dbh->is_persistent);
-               }
+       }
+
+       if (einfo->errmsg) {
+               pefree(einfo->errmsg, dbh->is_persistent);
        }
 
        einfo->errmsg = NULL;
index d51a0ad170c8b4e1da213a89e6e479a52f8911b4..d4fa3b9f3575a5b5f29ac8e780cbb0562a8cad30 100755 (executable)
@@ -87,7 +87,7 @@ static int oci_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC) /* {{{ */
        }
 
        if (S->einfo.errmsg) {
-               efree(S->einfo.errmsg);
+               pefree(S->einfo.errmsg, stmt->dbh->is_persistent);
                S->einfo.errmsg = NULL;
        }
 
diff --git a/ext/pdo_oci/tests/bug44301.phpt b/ext/pdo_oci/tests/bug44301.phpt
new file mode 100644 (file)
index 0000000..c0f7935
--- /dev/null
@@ -0,0 +1,25 @@
+--TEST--
+PDO OCI Bug #44301 (Segfault when an exception is thrown on persistent connections)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded');
+require dirname(__FILE__).'/../../pdo/tests/pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+putenv("PDO_OCI_TEST_ATTR=" . serialize(array(PDO::ATTR_PERSISTENT => true)));
+require 'ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory('ext/pdo_oci/tests/common.phpt');
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+
+try {
+    $stmt = $db->prepare('SELECT * FROM no_table');
+    $stmt->execute();
+} catch (PDOException $e) {
+    print $e->getMessage();
+}
+$db = null;
+--EXPECTF--
+SQLSTATE[HY000]: General error: 942 OCIStmtExecute: ORA-00942: table or view does not exist
+ (%s/ext/pdo_oci/oci_statement.c:%d)