Skip to content

Commit 1fcea24

Browse files
committed
Fix php_pgsql_fd_cast() wrt. php_stream_can_cast()
`php_stream_can_cast()` forwards to `_php_stream_cast()` with `ret` set to `NULL`. `php_pgsql_fd_cast()` needs to cater to that, because otherwise the stream would report that it is not castable. This *might* fix https://bugs.php.net/73903. Closes phpGH-6888.
1 parent 263f14a commit 1fcea24

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ PHP NEWS
88
. Fixed bug #80960 (opendir() warning wrong info when failed on Windows).
99
(cmb)
1010

11+
- pgsql:
12+
. Fixed php_pgsql_fd_cast() wrt. php_stream_can_cast(). (cmb)
13+
1114
- SPL:
1215
. Fixed bug #80933 (SplFileObject::DROP_NEW_LINE is broken for NUL and CR).
1316
(cmb, Nikita)

ext/pgsql/pgsql.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -5418,16 +5418,17 @@ static int php_pgsql_fd_cast(php_stream *stream, int cast_as, void **ret) /* {{{
54185418
switch (cast_as) {
54195419
case PHP_STREAM_AS_FD_FOR_SELECT:
54205420
case PHP_STREAM_AS_FD:
5421-
case PHP_STREAM_AS_SOCKETD:
5422-
if (ret) {
5421+
case PHP_STREAM_AS_SOCKETD: {
54235422
int fd_number = PQsocket(pgsql);
54245423
if (fd_number == -1) {
54255424
return FAILURE;
54265425
}
54275426

5428-
*(php_socket_t *)ret = fd_number;
5429-
return SUCCESS;
5427+
if (ret) {
5428+
*(php_socket_t *)ret = fd_number;
5429+
}
54305430
}
5431+
return SUCCESS;
54315432
default:
54325433
return FAILURE;
54335434
}

0 commit comments

Comments
 (0)