#37096 [Com]: referencing bug with return value for stream_seek
| From: | tendencies at free dot fr | Date: | Wed, 26 Jul 2006 09:21:28 +0000 |
| Subject: | #37096 [Com]: referencing bug with return value for stream_seek | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-99905@lists.php.net to get a copy of this message | ||
ID: 37096
Comment by: tendencies at free dot fr
Reported By: wez@php.net
Status: Open
Bug Type: Streams related
Operating System: *
PHP Version: 5CVS-2006-04-16 (CVS)
New Comment:
See this bug : http://bugs.php.net/bug.php?id=30157
Previous Comments:
------------------------------------------------------------------------
[2006-04-16 02:29:02] wez@php.net
Description:
------------
When using user-space streams via stream_wrapper_register(),
if you return the value of a property of the object from stream_seek(),
it gets mangled.
Sounds like a problem with the way that the retval from
call_user_function_ex() is disposed.
The workaround is to create a temporary value using a trick like this:
function stream_seek($offset, $whence) {
...
$retval = $this->pos + 0;
return $retval;
}
presumably the rest of the user wrapper code has the same flaw.
Reproduce code:
---------------
Abbreviated example; my actual test case is too large.
Valgrind does not indicate any memory errors, so the problem is likely
logical rather than sloppy memory handling.
class MyStream {
var $this->pos = 0;
function stream_tell() {
return $this->pos;
}
function stream_seek($offset, $whence) {
return $this->pos;
}
}
Actual result:
--------------
Problem manifested for me by converting $this->pos to bool(true), which
was then interpreted by the user space wrapper as an invalid return
value from stream_tell(), which simply returns $this->pos.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37096&edit=1