|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-01-02 21:30 UTC] giovanni at giacobbi dot net
Description:
------------
See the example code. It should return FALSE according to the manual (and to common good sense).
This is causing valid code like
while (($str = fgets($fd)) !== FALSE) {
...
}
to go into infinite loop, which is very bad.
I tried to look at the source code but it looks correct, as it should fall in file.c:1395, at the exit_failed label.
Reproduce code:
---------------
<?php
$fd = FALSE;
$retval = @fgets($fd);
var_dump($retval);
Expected result:
----------------
FALSE
Actual result:
--------------
NULL
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 04:00:01 2025 UTC |
ok ok, i got it. Follows a working patch. Well, the patch is just a hack in my opinion, but.. hey, if there is a "php_stream_from_zval_no_verify" macro it means you already hacked it for something.. Maybe i haven't understood the API structure very well yet, but can php_streams.h access directly zend_fetch_resource() without using a zend_list.h macro? --- php-4.3.4/ext/standard/file.c.orig 2003-10-10 03:38:01.000000000 +0200 +++ php-4.3.4/ext/standard/file.c 2004-01-03 04:08:04.000000000 +0100 @@ -1358,7 +1358,10 @@ WRONG_PARAM_COUNT; } - php_stream_from_zval(stream, arg1); + /* we want our way to handle the error */ + php_stream_from_zval_no_verify(stream, arg1); + if (!stream) + goto exit_failed; if (argc == 1) { /* ask streams to give us a buffer of an appropriate size */