[php-src] PHP-8.5: Fix GH-23758: PDO_Firebird returns null for empty BLOBs (#23763)
| From: | lazerg via Saki Takamachi | Date: | Tue, 29 Sep 2026 11:55:56 +0000 |
| Subject: | [php-src] PHP-8.5: Fix GH-23758: PDO_Firebird returns null for empty BLOBs (#23763) | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-141672@lists.php.net to get a copy of this message | ||
Author: lazerg (lazerg)
Committer: Saki Takamachi (SakiTakamachi)
Date: 2026-09-29T20:48:16+09:00
Commit: https://github.com/php/php-src/commit/48c0ffa899934f2d24dbef5e385b3a6ffce72eab
Raw diff: https://github.com/php/php-src/commit/48c0ffa899934f2d24dbef5e385b3a6ffce72eab.diff
Fix GH-23758: PDO_Firebird returns null for empty BLOBs (#23763)
Fixes #23758
Closes #23763
Changed paths:
A ext/pdo_firebird/tests/gh23758.phpt
M NEWS
M ext/pdo_firebird/firebird_statement.c
Diff:
diff --git a/NEWS b/NEWS
index 7468a6982530..2e5b71aa8fc0 100644
--- a/NEWS
+++ b/NEWS
@@ -103,6 +103,10 @@ PHP NEWS
. Fixed bug GH-23962 (Destroying a persistent PDO instance rolls back a
transaction still in use by another instance). (Lazizbek Ergashev)
+- PDO_Firebird:
+ . Fixed bug GH-23758 (PDO_Firebird returns null for non-null empty BLOBs).
+ (Lazizbek Ergashev)
+
- Readline:
. Fixed a heap over-read in the interactive shell prompt when cli.prompt is
set to an empty string. (Ilia Alshanetsky)
diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c
index 50db55947696..b8802751bf9b 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.c
@@ -446,6 +446,8 @@ static int php_firebird_fetch_blob(pdo_stmt_t *stmt, int colno, zval *result, IS
php_firebird_error_stmt_with_info(stmt, "HY000", strlen("HY000"), msg,
strlen(msg));
goto fetch_blob_end;
}
+ } else {
+ ZVAL_EMPTY_STRING(result);
}
retval = 1;
diff --git a/ext/pdo_firebird/tests/gh23758.phpt b/ext/pdo_firebird/tests/gh23758.phpt
new file mode 100644
index 000000000000..5f90d2ddbc8b
--- /dev/null
+++ b/ext/pdo_firebird/tests/gh23758.phpt
@@ -0,0 +1,52 @@
+--TEST--
+GH-23758 (PDO_Firebird returns null for non-null empty BLOBs)
+--EXTENSIONS--
+pdo_firebird
+--SKIPIF--
+<?php require('skipif.inc'); ?>
+--XLEAK--
+A bug in firebird causes a memory leak when calling
isc_attach_database().
+See https://github.com/FirebirdSQL/firebird/issues/7849
+--FILE--
+<?php
+
+require("testdb.inc");
+
+$dbh = getDbConnection();
+$dbh->exec('CREATE TABLE gh23758 (ID INTEGER, BIN_VAL BLOB SUB_TYPE BINARY, TEXT_VAL BLOB
SUB_TYPE TEXT)');
+
+$stmt = $dbh->prepare('INSERT INTO gh23758 VALUES (?, ?, ?)');
+$stmt->execute([1, null, null]);
+$stmt->execute([2, '', '']);
+
+$stmt = $dbh->query('SELECT BIN_VAL, TEXT_VAL FROM gh23758 ORDER BY ID');
+var_dump($stmt->fetchAll(PDO::FETCH_NUM));
+
+unset($stmt);
+unset($dbh);
+
+?>
+--CLEAN--
+<?php
+require 'testdb.inc';
+$dbh = getDbConnection();
+@$dbh->exec('DROP TABLE gh23758');
+unset($dbh);
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ array(2) {
+ [0]=>
+ NULL
+ [1]=>
+ NULL
+ }
+ [1]=>
+ array(2) {
+ [0]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ }
+}