Skip to content

Commit ff1bb60

Browse files
committed
Merge branch 'PHP-8.6'
* PHP-8.6: Fix GH-23758: PDO_Firebird returns null for empty BLOBs (#23763)
2 parents 94db015 + bf85586 commit ff1bb60

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

‎ext/pdo_firebird/firebird_statement.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,8 @@ static int php_firebird_fetch_blob(pdo_stmt_t *stmt, int colno, zval *result, IS
436436
php_firebird_error_stmt_with_info(stmt, "HY000", strlen("HY000"), msg, strlen(msg));
437437
goto fetch_blob_end;
438438
}
439+
} else {
440+
ZVAL_EMPTY_STRING(result);
439441
}
440442
retval = 1;
441443

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
--TEST--
2+
GH-23758 (PDO_Firebird returns null for non-null empty BLOBs)
3+
--EXTENSIONS--
4+
pdo_firebird
5+
--SKIPIF--
6+
<?php require('skipif.inc'); ?>
7+
--XLEAK--
8+
A bug in firebird causes a memory leak when calling `isc_attach_database()`.
9+
See https://github.com/FirebirdSQL/firebird/issues/7849
10+
--FILE--
11+
<?php
12+
13+
require("testdb.inc");
14+
15+
$dbh = getDbConnection();
16+
$dbh->exec('CREATE TABLE gh23758 (ID INTEGER, BIN_VAL BLOB SUB_TYPE BINARY, TEXT_VAL BLOB SUB_TYPE TEXT)');
17+
18+
$stmt = $dbh->prepare('INSERT INTO gh23758 VALUES (?, ?, ?)');
19+
$stmt->execute([1, null, null]);
20+
$stmt->execute([2, '', '']);
21+
22+
$stmt = $dbh->query('SELECT BIN_VAL, TEXT_VAL FROM gh23758 ORDER BY ID');
23+
var_dump($stmt->fetchAll(PDO::FETCH_NUM));
24+
25+
unset($stmt);
26+
unset($dbh);
27+
28+
?>
29+
--CLEAN--
30+
<?php
31+
require 'testdb.inc';
32+
$dbh = getDbConnection();
33+
@$dbh->exec('DROP TABLE gh23758');
34+
unset($dbh);
35+
?>
36+
--EXPECT--
37+
array(2) {
38+
[0]=>
39+
array(2) {
40+
[0]=>
41+
NULL
42+
[1]=>
43+
NULL
44+
}
45+
[1]=>
46+
array(2) {
47+
[0]=>
48+
string(0) ""
49+
[1]=>
50+
string(0) ""
51+
}
52+
}

0 commit comments

Comments
 (0)