]> granicus.if.org Git - php/commitdiff
Fixed bug #51997 (SEEK_CUR with 0 value, returns a warning).
authorIlia Alshanetsky <iliaa@php.net>
Sun, 5 Jun 2011 21:57:01 +0000 (21:57 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 5 Jun 2011 21:57:01 +0000 (21:57 +0000)
NEWS
ext/bz2/tests/bug51997.phpt [new file with mode: 0644]
main/streams/streams.c

diff --git a/NEWS b/NEWS
index cc522cf53f1f543920ea324d5fff45053ce64b8e..f30d8dadea0239efc218a7edbf12fa232a2e96bd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -47,6 +47,7 @@ PHP                                                                        NEWS
   . Fixed bug #54721 (Different Hashes on Windows, BSD and Linux on wrong Salt size) 
     (Pierre, os at irj dot ru)
   . Fixed bug #53848 (fgetcsv() ignores spaces at beginnings of fields). (Ilia)
+  . Fixed bug #51997 (SEEK_CUR with 0 value, returns a warning). (Ilia)
   . Fixed bug #50363 (Invalid parsing in convert.quoted-printable-decode filter).
     (slusarz at curecanti dot org)
   . Fixed bug #48465 (sys_get_temp_dir() possibly inconsistent when using 
diff --git a/ext/bz2/tests/bug51997.phpt b/ext/bz2/tests/bug51997.phpt
new file mode 100644 (file)
index 0000000..fea5398
--- /dev/null
@@ -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.
index 5029f5cd02412d8ca3c3950dbe04cd866ce7be83..eb2eb07082ba8b12a4d6de453431801aa31f7f31 100755 (executable)
@@ -1184,7 +1184,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) {