[PECL-CVS] [pecl-database-pdo_oci] pdo_bind_io_fix: Fix for Input Output Bind issue

[email protected] (Sharad Chandran R)
Newsgroups php.pecl.cvs
Message-ID <[email protected]>
Author: Sharad Chandran R (sharadraju)
Date: 2026-01-06T15:46:20+05:30

Commit: https://github.com/php/pecl-database-pdo_oci/commit/e8bf68ef08f3b0c57ba77b1554e49a38fae2d3c9
Raw diff: https://github.com/php/pecl-database-pdo_oci/commit/e8bf68ef08f3b0c57ba77b1554e49a38fae2d3c9.diff

Fix for Input Output Bind issue

Changed paths:
  A  tests/pdo_oci_bind_input_output.phpt
  M  CREDITS
  M  oci_statement.c


Diff:

diff --git a/CREDITS b/CREDITS
index 8d9f86c..a4b8c68 100644
--- a/CREDITS
+++ b/CREDITS
@@ -2,3 +2,4 @@ Oracle (OCI) driver for PDO
 Wez Furlong
 Michael Voříšek
 Ashutosh Agrawal
+Neils Dossche
\ No newline at end of file
diff --git a/oci_statement.c b/oci_statement.c
index 440055b..5f8f062 100644
--- a/oci_statement.c
+++ b/oci_statement.c
@@ -278,7 +278,7 @@ static sb4 oci_bind_output_cb(dvoid *ctx, OCIBind *bindp, ub4 iter, ub4 index, d
 
 	zval_ptr_dtor(parameter);
 
-	Z_STR_P(parameter) = zend_string_alloc(param->max_value_len, 1);
+	ZVAL_NEW_STR(parameter, zend_string_alloc(param->max_value_len, false));
 	P->used_for_output = 1;
 
 	P->actual_len = (ub4) Z_STRLEN_P(parameter);
@@ -397,7 +397,8 @@ static int oci_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *pa
 						zval_ptr_dtor_str(parameter);
 						ZVAL_UNDEF(parameter);
 					} else if (Z_TYPE_P(parameter) == IS_STRING) {
-						Z_STR_P(parameter) = zend_string_init(Z_STRVAL_P(parameter), P->actual_len, 1);
+						ZVAL_STR(parameter, zend_string_truncate(Z_STR_P(parameter), P->actual_len, false));
+						Z_STRVAL_P(parameter)[Z_STRLEN_P(parameter)] = '\0';
 					}
 				} else if (PDO_PARAM_TYPE(param->param_type) == PDO_PARAM_LOB && P->thing) {
 					php_stream *stm;
diff --git a/tests/pdo_oci_bind_input_output.phpt b/tests/pdo_oci_bind_input_output.phpt
new file mode 100644
index 0000000..3110f10
--- /dev/null
+++ b/tests/pdo_oci_bind_input_output.phpt
@@ -0,0 +1,34 @@
+--TEST--
+PDO_OCI: Test input/output parameter binding
+--EXTENSIONS--
+pdo
+pdo_oci
+--SKIPIF--
+<?php
+require(getenv('PDO_TEST_DIR').'/pdo_test.inc');
+PDOTest::skip();
+?>
+--FILE--
+<?php
+
+require_once(getenv('PDO_TEST_DIR').'/pdo_test.inc');
+
+$dbh = PDOTest::factory();
+$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+$dbh->setAttribute(PDO::ATTR_AUTOCOMMIT, false);
+
+$sql = <<<SQL
+    begin
+        :p := :p + 100;
+    end;
+SQL;
+
+$stmt = $dbh->prepare($sql);
+$p = -1;
+$stmt->bindParam(':p', $p, PDO::PARAM_INT | PDO::PARAM_INPUT_OUTPUT, 10);
+$stmt->execute();
+var_dump($p);
+
+?>
+--EXPECT--
+string(2) "99"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.