Skip to content

Commit d22da5e

Browse files
committed
Fix GH-23758: PDO_Firebird returns null for empty BLOBs
1 parent b55c619 commit d22da5e

3 files changed

Lines changed: 58 additions & 0 deletions

File tree

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ PHP NEWS
3232
. Fixed PDOStatement::getColumnMeta() reading out of bounds for an invalid
3333
column index. (Ilia Alshanetsky)
3434

35+
- PDO_Firebird:
36+
. Fixed bug GH-23758 (PDO_Firebird returns null for non-null empty BLOBs).
37+
(Lazizbek Ergashev)
38+
3539
- Sockets:
3640
. Fixed socket_select() silently truncating sets larger than FD_SETSIZE on
3741
Windows. (David Carlier)

ext/pdo_firebird/firebird_statement.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,8 @@ static int php_firebird_fetch_blob(pdo_stmt_t *stmt, int colno, zval *result, IS
446446
php_firebird_error_stmt_with_info(stmt, "HY000", strlen("HY000"), msg, strlen(msg));
447447
goto fetch_blob_end;
448448
}
449+
} else {
450+
ZVAL_EMPTY_STRING(result);
449451
}
450452
retval = 1;
451453

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)