Modified: php/php-src/branches/PHP_5_3/ext/oci8/oci8_statement.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/oci8/oci8_statement.c 2010-04-29 05:07:03 UTC (rev 298754)
+++ php/php-src/branches/PHP_5_3/ext/oci8/oci8_statement.c 2010-04-29 05:07:16 UTC (rev 298755)
@@ -880,7 +880,15 @@
}
zval_dtor(val);
ZVAL_NULL(val);
- } else if (Z_TYPE_P(bind->zval) == IS_STRING && Z_STRLEN_P(bind->zval) > 0) {
+ } else if (Z_TYPE_P(bind->zval) == IS_STRING
+ && Z_STRLEN_P(bind->zval) > 0
+ && Z_STRVAL_P(bind->zval)[ Z_STRLEN_P(bind->zval) ] != '\0') {
+ /* The post- PHP 5.3 feature for "interned" strings disallows
+ * their reallocation but (i) any IN binds either interned or
+ * not should already be null terminated and (ii) for OUT
+ * binds, php_oci_bind_out_callback() should have allocated a
+ * new string that can be realloced.
+ */
Z_STRVAL_P(bind->zval) = erealloc(Z_STRVAL_P(bind->zval), Z_STRLEN_P(bind->zval)+1);
Z_STRVAL_P(bind->zval)[ Z_STRLEN_P(bind->zval) ] = '\0';
} else if (Z_TYPE_P(bind->zval) == IS_ARRAY) {
Modified: php/php-src/branches/PHP_5_3/ext/oci8/package.xml
===================================================================
--- php/php-src/branches/PHP_5_3/ext/oci8/package.xml 2010-04-29 05:07:03 UTC (rev 298754)
+++ php/php-src/branches/PHP_5_3/ext/oci8/package.xml 2010-04-29 05:07:16 UTC (rev 298755)
@@ -33,7 +33,7 @@
no
- 2010-02-11
+ 2010-03-30
@@ -41,12 +41,14 @@
1.4.2
- development
- development
+ devel
+ devel
PHP
+ Fixed Bug #51691 (Unnecessary realloc causes crashes in PHP trunk tests with interned strings)
Fixed bug #51291 (oci_error doesn't report last error when called two times)
+ Fixed Bug #51577 (Uninitialized memory reference with oci_bind_array_by_name)
@@ -76,20 +78,38 @@
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -118,7 +138,8 @@
-
+
+
@@ -152,8 +173,9 @@
+
+
-
@@ -182,17 +204,22 @@
+
+
+
+
+
@@ -214,11 +241,14 @@
+
+
+
@@ -226,6 +256,7 @@
+
@@ -236,12 +267,15 @@
+
+
+
@@ -299,7 +333,6 @@
-
@@ -309,6 +342,7 @@
+
@@ -320,7 +354,6 @@
-
Modified: php/php-src/branches/PHP_5_3/ext/oci8/tests/bind_empty.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/oci8/tests/bind_empty.phpt 2010-04-29 05:07:03 UTC (rev 298754)
+++ php/php-src/branches/PHP_5_3/ext/oci8/tests/bind_empty.phpt 2010-04-29 05:07:16 UTC (rev 298755)
@@ -7,11 +7,11 @@
require dirname(__FILE__).'/connect.inc';
-$drop = "DROP table bind_test";
+$drop = "DROP table bind_empty_tab";
$statement = oci_parse($c, $drop);
@oci_execute($statement);
-$create = "CREATE table bind_test(name VARCHAR(10))";
+$create = "CREATE table bind_empty_tab(name VARCHAR(10))";
$statement = oci_parse($c, $create);
oci_execute($statement);
@@ -19,7 +19,7 @@
echo "Test 1\n";
$name = null;
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name");
oci_bind_by_name($stmt, ":name", $name);
var_dump(oci_execute($stmt));
@@ -27,26 +27,26 @@
echo "Test 2\n";
$name = "";
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name");
oci_bind_by_name($stmt, ":name", $name);
var_dump(oci_execute($stmt));
echo "Test 3\n";
-$stmt = oci_parse($c, "INSERT INTO bind_test (NAME) VALUES ('abc')");
+$stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('abc')");
$res = oci_execute($stmt);
-$stmt = oci_parse($c, "INSERT INTO bind_test (NAME) VALUES ('def')");
+$stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('def')");
$res = oci_execute($stmt);
$name = null;
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name WHERE NAME = 'abc'");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name WHERE NAME = 'abc'");
oci_bind_by_name($stmt, ":name", $name);
var_dump(oci_execute($stmt));
-$stid = oci_parse($c, "select * from bind_test order by 1");
+$stid = oci_parse($c, "select * from bind_empty_tab order by 1");
oci_execute($stid);
oci_fetch_all($stid, $res);
var_dump($res);
@@ -54,26 +54,43 @@
echo "Test 4\n";
$name = "";
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name WHERE NAME = 'def'");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name WHERE NAME = 'def'");
oci_bind_by_name($stmt, ":name", $name);
var_dump(oci_execute($stmt));
-$stid = oci_parse($c, "select * from bind_test order by 1");
+$stid = oci_parse($c, "select * from bind_empty_tab order by 1");
oci_execute($stid);
oci_fetch_all($stid, $res);
var_dump($res);
+echo "Test 5\n";
+$av = $bv = 'old';
+$s = oci_parse($c, "begin :bv := null; end; ");
+oci_bind_by_name($s, ":bv", $bv);
+oci_execute($s);
+var_dump($av);
+var_dump($bv);
+
+echo "Test 6\n";
+
+$av = $bv = null;
+$s = oci_parse($c, "begin :bv := null; end; ");
+oci_bind_by_name($s, ":bv", $bv);
+oci_execute($s);
+var_dump($av);
+var_dump($bv);
+
// Clean up
-$drop = "DROP table bind_test";
+$drop = "DROP table bind_empty_tab";
$statement = oci_parse($c, $drop);
@oci_execute($statement);
-echo "Done\n";
-
?>
+===DONE===
+
--EXPECTF--
Test 1
bool(true)
@@ -101,4 +118,10 @@
NULL
}
}
-Done
+Test 5
+string(3) "old"
+NULL
+Test 6
+NULL
+NULL
+===DONE===
Modified: php/php-src/trunk/ext/oci8/oci8_statement.c
===================================================================
--- php/php-src/trunk/ext/oci8/oci8_statement.c 2010-04-29 05:07:03 UTC (rev 298754)
+++ php/php-src/trunk/ext/oci8/oci8_statement.c 2010-04-29 05:07:16 UTC (rev 298755)
@@ -880,7 +880,15 @@
}
zval_dtor(val);
ZVAL_NULL(val);
- } else if (Z_TYPE_P(bind->zval) == IS_STRING && Z_STRLEN_P(bind->zval) > 0) {
+ } else if (Z_TYPE_P(bind->zval) == IS_STRING
+ && Z_STRLEN_P(bind->zval) > 0
+ && Z_STRVAL_P(bind->zval)[ Z_STRLEN_P(bind->zval) ] != '\0') {
+ /* The post- PHP 5.3 feature for "interned" strings disallows
+ * their reallocation but (i) any IN binds either interned or
+ * not should already be null terminated and (ii) for OUT
+ * binds, php_oci_bind_out_callback() should have allocated a
+ * new string that we can modify here.
+ */
Z_STRVAL_P(bind->zval) = erealloc(Z_STRVAL_P(bind->zval), Z_STRLEN_P(bind->zval)+1);
Z_STRVAL_P(bind->zval)[ Z_STRLEN_P(bind->zval) ] = '\0';
} else if (Z_TYPE_P(bind->zval) == IS_ARRAY) {
Modified: php/php-src/trunk/ext/oci8/tests/bind_empty.phpt
===================================================================
--- php/php-src/trunk/ext/oci8/tests/bind_empty.phpt 2010-04-29 05:07:03 UTC (rev 298754)
+++ php/php-src/trunk/ext/oci8/tests/bind_empty.phpt 2010-04-29 05:07:16 UTC (rev 298755)
@@ -7,11 +7,11 @@
require dirname(__FILE__).'/connect.inc';
-$drop = "DROP table bind_test";
+$drop = "DROP table bind_empty_tab";
$statement = oci_parse($c, $drop);
@oci_execute($statement);
-$create = "CREATE table bind_test(name VARCHAR(10))";
+$create = "CREATE table bind_empty_tab(name VARCHAR(10))";
$statement = oci_parse($c, $create);
oci_execute($statement);
@@ -19,7 +19,7 @@
echo "Test 1\n";
$name = null;
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name");
oci_bind_by_name($stmt, ":name", $name);
var_dump(oci_execute($stmt));
@@ -27,26 +27,26 @@
echo "Test 2\n";
$name = "";
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name");
oci_bind_by_name($stmt, ":name", $name);
var_dump(oci_execute($stmt));
echo "Test 3\n";
-$stmt = oci_parse($c, "INSERT INTO bind_test (NAME) VALUES ('abc')");
+$stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('abc')");
$res = oci_execute($stmt);
-$stmt = oci_parse($c, "INSERT INTO bind_test (NAME) VALUES ('def')");
+$stmt = oci_parse($c, "INSERT INTO bind_empty_tab (NAME) VALUES ('def')");
$res = oci_execute($stmt);
$name = null;
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name WHERE NAME = 'abc'");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name WHERE NAME = 'abc'");
oci_bind_by_name($stmt, ":name", $name);
var_dump(oci_execute($stmt));
-$stid = oci_parse($c, "select * from bind_test order by 1");
+$stid = oci_parse($c, "select * from bind_empty_tab order by 1");
oci_execute($stid);
oci_fetch_all($stid, $res);
var_dump($res);
@@ -54,26 +54,43 @@
echo "Test 4\n";
$name = "";
-$stmt = oci_parse($c, "UPDATE bind_test SET name=:name WHERE NAME = 'def'");
+$stmt = oci_parse($c, "UPDATE bind_empty_tab SET name=:name WHERE NAME = 'def'");
oci_bind_by_name($stmt, ":name", $name);
var_dump(oci_execute($stmt));
-$stid = oci_parse($c, "select * from bind_test order by 1");
+$stid = oci_parse($c, "select * from bind_empty_tab order by 1");
oci_execute($stid);
oci_fetch_all($stid, $res);
var_dump($res);
+echo "Test 5\n";
+$av = $bv = 'old';
+$s = oci_parse($c, "begin :bv := null; end; ");
+oci_bind_by_name($s, ":bv", $bv);
+oci_execute($s);
+var_dump($av);
+var_dump($bv);
+
+echo "Test 6\n";
+
+$av = $bv = null;
+$s = oci_parse($c, "begin :bv := null; end; ");
+oci_bind_by_name($s, ":bv", $bv);
+oci_execute($s);
+var_dump($av);
+var_dump($bv);
+
// Clean up
-$drop = "DROP table bind_test";
+$drop = "DROP table bind_empty_tab";
$statement = oci_parse($c, $drop);
@oci_execute($statement);
-echo "Done\n";
-
?>
+===DONE===
+
--EXPECTF--
Test 1
bool(true)
@@ -101,4 +118,10 @@
NULL
}
}
-Done
+Test 5
+string(3) "old"
+NULL
+Test 6
+NULL
+NULL
+===DONE===