Skip to content

Commit

Permalink
Fix php_pgsql_fd_cast() wrt. php_stream_can_cast()
Browse files Browse the repository at this point in the history
`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 GH-6888.
  • Loading branch information
cmb69 committed Apr 20, 2021
1 parent 263f14a commit 1fcea24
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ PHP NEWS
. Fixed bug #80960 (opendir() warning wrong info when failed on Windows).
(cmb)

- pgsql:
. Fixed php_pgsql_fd_cast() wrt. php_stream_can_cast(). (cmb)

- SPL:
. Fixed bug #80933 (SplFileObject::DROP_NEW_LINE is broken for NUL and CR).
(cmb, Nikita)
Expand Down
9 changes: 5 additions & 4 deletions ext/pgsql/pgsql.c
Original file line number Diff line number Diff line change
Expand Up @@ -5418,16 +5418,17 @@ static int php_pgsql_fd_cast(php_stream *stream, int cast_as, void **ret) /* {{{
switch (cast_as) {
case PHP_STREAM_AS_FD_FOR_SELECT:
case PHP_STREAM_AS_FD:
case PHP_STREAM_AS_SOCKETD:
if (ret) {
case PHP_STREAM_AS_SOCKETD: {
int fd_number = PQsocket(pgsql);
if (fd_number == -1) {
return FAILURE;
}

*(php_socket_t *)ret = fd_number;
return SUCCESS;
if (ret) {
*(php_socket_t *)ret = fd_number;
}
}
return SUCCESS;
default:
return FAILURE;
}
Expand Down

0 comments on commit 1fcea24

Please sign in to comment.