]> granicus.if.org Git - php/commitdiff
Avoid Bug #28363 by not seeking if we don't have a read buffer
authorWez Furlong <wez@php.net>
Wed, 12 May 2004 10:46:30 +0000 (10:46 +0000)
committerWez Furlong <wez@php.net>
Wed, 12 May 2004 10:46:30 +0000 (10:46 +0000)
main/streams.c

index 52e14ac5b25971b9cc2c4850c0d34441052a29a9..14d0bc827e09f862caeb03a84ba55dce36b2e7cd 100755 (executable)
@@ -896,7 +896,7 @@ PHPAPI size_t _php_stream_write(php_stream *stream, const char *buf, size_t coun
        /* if we have a seekable stream we need to ensure that data is written at the
         * current stream->position. This means invalidating the read buffer and then
         * performing a low-level seek */
-       if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0) {
+       if (stream->ops->seek && (stream->flags & PHP_STREAM_FLAG_NO_SEEK) == 0 && stream->writepos > stream->readpos) {
                stream->readpos = stream->writepos = 0;
 
                stream->ops->seek(stream, stream->position, SEEK_SET, &stream->position TSRMLS_CC);