uv_stdio_new() without args now creates an UVStdio with UV_IGNORE (Closes #73)

This commit is contained in:
Bob Weinand 2020-02-15 22:51:35 +01:00
parent 99312394a7
commit 515476f765
2 changed files with 6 additions and 4 deletions

View File

@ -4772,7 +4772,7 @@ PHP_FUNCTION(uv_pipe_pending_type)
}
/* }}} */
/* {{{ proto UVStdio uv_stdio_new(UV|resource|long $fd[, long $flags = 0])
/* {{{ proto UVStdio uv_stdio_new([UV|resource|long|null $fd[, long $flags = 0]])
*/
PHP_FUNCTION(uv_stdio_new)
{
@ -4786,11 +4786,13 @@ PHP_FUNCTION(uv_stdio_new)
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS(),
"z|l", &handle, &flags) == FAILURE) {
"|zl", &handle, &flags) == FAILURE) {
return;
}
if (Z_TYPE_P(handle) == IS_LONG) {
if (handle == NULL || Z_TYPE_P(handle) == IS_NULL) {
flags = UV_IGNORE;
} else if (Z_TYPE_P(handle) == IS_LONG) {
fd = Z_LVAL_P(handle);
if (flags & (UV_CREATE_PIPE | UV_INHERIT_STREAM)) {
php_error_docref(NULL, E_WARNING, "flags must not be UV::CREATE_PIPE or UV::INHERIT_STREAM for resources");

View File

@ -3,7 +3,7 @@ Test uv_stdio_new doesn't cause segfault #56
--FILE--
<?php
$ioRead = uv_stdio_new(null, Uv::CREATE_PIPE | Uv::INHERIT_STREAM);
$ioRead = uv_stdio_new("foo", Uv::CREATE_PIPE | Uv::INHERIT_STREAM);
--EXPECTF--
Warning: uv_stdio_new(): passed unexpected value, expected instance of UV, file resource or socket resource in %s on line %d