self->smax = -1;
self->mode = mode;
- stream = php_stream_alloc(&php_stream_memory_ops, self, 0, "r+b");
+ stream = php_stream_alloc(&php_stream_memory_ops, self, 0, mode & TEMP_STREAM_READONLY ? "r+b" : "w+b");
stream->flags |= PHP_STREAM_FLAG_NO_BUFFER;
return stream;
}
self = ecalloc(1, sizeof(*self));
self->smax = max_memory_usage;
self->mode = mode;
- stream = php_stream_alloc(&php_stream_temp_ops, self, 0, "r+b");
+ stream = php_stream_alloc(&php_stream_temp_ops, self, 0, mode & TEMP_STREAM_READONLY ? "r+b" : "w+b");
stream->flags |= PHP_STREAM_FLAG_NO_BUFFER;
self->innerstream = php_stream_memory_create(mode);
php_stream *stream;
php_stream_temp_data *ms;
- if ((stream = php_stream_temp_create_rel(mode & ~TEMP_STREAM_READONLY, max_memory_usage)) != NULL) {
+ if ((stream = php_stream_temp_create_rel(mode, max_memory_usage)) != NULL) {
if (length) {
assert(buf != NULL);
php_stream_temp_write(stream, buf, length TSRMLS_CC);