diff options
| author | Felipe Pena <felipe@php.net> | 2008-10-30 14:36:34 +0000 |
|---|---|---|
| committer | Felipe Pena <felipe@php.net> | 2008-10-30 14:36:34 +0000 |
| commit | 94e5be1bdc42399013a72ae040d5da0f8e2efec9 (patch) | |
| tree | 4c4f2ae810ccc170c184f3ec15ee1abf82f9904f | |
| parent | 930fad7381719397beec566f283b2395bc685ac9 (diff) | |
| download | php-git-94e5be1bdc42399013a72ae040d5da0f8e2efec9.tar.gz | |
MFH:
- Fix the fix
- Improved test
| -rw-r--r-- | ext/standard/streamsfuncs.c | 2 | ||||
| -rw-r--r-- | ext/standard/tests/streams/bug46426.phpt | 18 |
2 files changed, 16 insertions, 4 deletions
diff --git a/ext/standard/streamsfuncs.c b/ext/standard/streamsfuncs.c index 4a7644d3c3..d84cfc538c 100644 --- a/ext/standard/streamsfuncs.c +++ b/ext/standard/streamsfuncs.c @@ -406,7 +406,7 @@ PHP_FUNCTION(stream_get_contents) php_stream_from_zval(stream, &zsrc); - if (pos >= 0 && php_stream_seek(stream, pos, SEEK_SET) < 0) { + if ((pos > 0 || (pos == 0 && ZEND_NUM_ARGS() > 2)) && php_stream_seek(stream, pos, SEEK_SET) < 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to seek to position %ld in the stream", pos); RETURN_FALSE; } diff --git a/ext/standard/tests/streams/bug46426.phpt b/ext/standard/tests/streams/bug46426.phpt index 05bc9c1e3c..8c95ea456e 100644 --- a/ext/standard/tests/streams/bug46426.phpt +++ b/ext/standard/tests/streams/bug46426.phpt @@ -7,16 +7,28 @@ $tmp = tmpfile(); fwrite($tmp, "12345"); -echo stream_get_contents($tmp, -1, 0); +echo stream_get_contents($tmp, 2, 1); +echo "\n"; +echo stream_get_contents($tmp, -1); echo "\n"; -echo stream_get_contents($tmp, -1, 1); +echo stream_get_contents($tmp, -1, 0); echo "\n"; echo stream_get_contents($tmp, -1, 2); +echo "\n"; +echo stream_get_contents($tmp, 0, 0); +echo "\n"; +echo stream_get_contents($tmp, 1, 0); +echo "\n"; +echo stream_get_contents($tmp, -1); @unlink($tmp); ?> --EXPECT-- +23 +45 12345 -2345 345 + +1 +2345 |
