diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2011-06-05 21:57:01 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2011-06-05 21:57:01 +0000 |
commit | a311dc244353f0ed88a273056224ee5c97cc4011 (patch) | |
tree | 3ee934a673a5406d7f111804269b60635162a8b0 | |
parent | 6f56bf1cfc94ce1d682f2d72bccc3723d0931a54 (diff) | |
download | php-git-a311dc244353f0ed88a273056224ee5c97cc4011.tar.gz |
Fixed bug #51997 (SEEK_CUR with 0 value, returns a warning).
-rw-r--r-- | ext/bz2/tests/bug51997.phpt | 24 | ||||
-rwxr-xr-x | main/streams/streams.c | 2 |
2 files changed, 25 insertions, 1 deletions
diff --git a/ext/bz2/tests/bug51997.phpt b/ext/bz2/tests/bug51997.phpt new file mode 100644 index 0000000000..fea5398947 --- /dev/null +++ b/ext/bz2/tests/bug51997.phpt @@ -0,0 +1,24 @@ +--TEST-- +Bug #51997 (SEEK_CUR with 0 value, returns a warning) +--SKIPIF-- +<?php if (!extension_loaded("bz2")) print "skip"; ?> +--FILE-- +<?php + +error_reporting(E_ALL); + +$filename = "testfile.bz2"; +$str = "This is a test string.\n"; +$bz = bzopen($filename, "w"); +bzwrite($bz, $str); +bzclose($bz); + +$bz = bzopen($filename, "r"); +fseek($bz, 0, SEEK_CUR); +print bzread($bz, 10); +print bzread($bz); +bzclose($bz); +unlink($filename); + +--EXPECT-- +This is a test string. diff --git a/main/streams/streams.c b/main/streams/streams.c index 1017f22124..673795971a 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -1255,7 +1255,7 @@ PHPAPI int _php_stream_seek(php_stream *stream, off_t offset, int whence TSRMLS_ } /* emulate forward moving seeks with reads */ - if (whence == SEEK_CUR && offset > 0) { + if (whence == SEEK_CUR && offset >= 0) { char tmp[1024]; size_t didread; while(offset > 0) { |