Bug #66638 [Opn]: Using SEEK_CUR to seek before start in php://memory produces incorrect results
Edit report at https://bugs.php.net/bug.php?id=66638&edit=1
ID: 66638
User updated by: madhusudancs at gmail dot com
Reported by: madhusudancs at gmail dot com
-Summary: Using SEEK_CUR to seek behind start in a produces
incorrect result
+Summary: Using SEEK_CUR to seek before start in php://memory
produces incorrect results
Status: Open
Type: Bug
Package: Streams related
Operating System: Linux (likely all)
PHP Version: master-Git-2014-02-03 (Git)
Block user comment: N
Private report: N
New Comment:
Updating the summary line
Previous Comments:
------------------------------------------------------------------------
[2014-02-03 23:58:25] madhusudancs at gmail dot com
Description:
------------
When using php://memory stream, attempting to seek behind the start position, produces incorrect
results.
Sample test case below (in the next field)
Test case should print the entire stream (all the bytes in the stream, but it prints an empty
string.
Test script:
---------------
<?php
$fh = fopen('php://memory', 'w');
for ($ii = 0; $ii < 10; $ii++) {
fwrite($fh, "[$ii] hello world. ");
}
$sz = 170;
fseek($fh, $sz - 100, SEEK_SET);
fseek($fh, -$sz, SEEK_CUR);
var_dump(fread($fh, $sz));
?>
Expected result:
----------------
string(170) "[0] hello world. [1] hello world. [2] hello world. [3] hello world. [4] hello
world. [5] hello world. [6] hello world. [7] hello world. [8] hello world. [9] hello world. "
Actual result:
--------------
string(0) ""
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66638&edit=1
Thread (3 messages)