Skip to content

Fix GH-10672 (pg_lo_open segfaults in the strict_types mode) #10677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -2464,7 +2464,7 @@ PHP_FUNCTION(pg_lo_open)
CHECK_PGSQL_LINK(link);
}
else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(),
"Ols", &pgsql_link, pgsql_link_ce, &oid_long, &mode) == SUCCESS) {
"OlS", &pgsql_link, pgsql_link_ce, &oid_long, &mode) == SUCCESS) {
if (oid_long <= (zend_long)InvalidOid) {
zend_value_error("Invalid OID value passed");
RETURN_THROWS();
Expand Down
43 changes: 43 additions & 0 deletions ext/pgsql/tests/gh10672.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
--TEST--
GH-10672 (pg_lo_open segfaults in the strict_types mode)
--EXTENSIONS--
pgsql
--SKIPIF--
<?php
include("skipif.inc");
?>
--FILE--
<?php
declare(strict_types=1);

include "config.inc";

function fee(&$a) {}
$a = ["bar" => "testing"];
fee($a["bar"]);

$db = pg_connect($conn_str);
pg_query($db, "DROP TABLE IF EXISTS gh10672");
pg_query($db, "CREATE TABLE gh10672 (bar text);");

// Begin a transaction
pg_query($db, 'BEGIN');

// Create an empty large object
$oid = pg_lo_create($db);

if ($oid === false) {
die(pg_last_error($db));
}

// Open the large object for writing
$lob = pg_lo_open($db, $oid, 'w');

if ($oid === false) {
die(pg_last_error($db));
}

echo 'The large object has been opened successfully.', PHP_EOL;
?>
--EXPECT--
The large object has been opened successfully.