summaryrefslogtreecommitdiff
path: root/main/streams/memory.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-07-21 09:26:43 +0200
committerAnatol Belski <ab@php.net>2014-07-21 09:26:43 +0200
commit0ff7fb02e11ce6cc2dec9bc10b22e552cf747999 (patch)
tree0624f622ae7e080eb49ff1d6828bd8b45627be77 /main/streams/memory.c
parent96783bdfb79b33646dc916d4b93bc33b78d70c4c (diff)
parentb131b03dc2ec4f3765e0d603b44f25c8029a3c2f (diff)
downloadphp-git-0ff7fb02e11ce6cc2dec9bc10b22e552cf747999.tar.gz
Merge remote-tracking branch 'origin/PHP-5.6' into str_size_and_int64_56_backport
* origin/PHP-5.6: (131 commits) Enable $ replacement in exif, ldap, pdo_pgsql and tidy See bug #67635 NEWS NEWS improve previous, add message during configure Fixed bug #67635 php links to systemd libraries without using pkg-config Improve fix for #66608 Fixed segfault with empty break New added opcodes don't need to be resloved Update NEWS Update NEWS Update NEWS Fixed bug #66827 Session raises E_NOTICE when session name variable is array implemented copy libs of core exts in phpize mode fix copy the ext dll into the prefix path in phpize mode fix default prefix in phpize mode fix file with zero size usage in phpize mode Update NEWS Fixed bug #66608 (Incorrect behavior with nested "finally" blocks) Enable build without atoll (e.g old AIX flavours) ... Conflicts: Zend/zend_opcode.c ext/date/php_date.c ext/mysqli/mysqli.c ext/pgsql/pgsql.c ext/session/session.c ext/spl/spl_array.c ext/standard/http_fopen_wrapper.c ext/standard/string.c sapi/litespeed/lsapi_main.c
Diffstat (limited to 'main/streams/memory.c')
-rw-r--r--main/streams/memory.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/main/streams/memory.c b/main/streams/memory.c
index d64054e999..b779ef34c8 100644
--- a/main/streams/memory.c
+++ b/main/streams/memory.c
@@ -352,6 +352,7 @@ typedef struct {
size_t smax;
int mode;
zval* meta;
+ char* tmpdir;
} php_stream_temp_data;
@@ -369,7 +370,7 @@ static size_t php_stream_temp_write(php_stream *stream, const char *buf, size_t
char *membuf = php_stream_memory_get_buffer(ts->innerstream, &memsize);
if (memsize + count >= ts->smax) {
- php_stream *file = php_stream_fopen_tmpfile();
+ php_stream *file = php_stream_fopen_temporary_file(ts->tmpdir, "php", NULL);
php_stream_write(file, membuf, memsize);
php_stream_free_enclosed(ts->innerstream, PHP_STREAM_FREE_CLOSE);
ts->innerstream = file;
@@ -420,6 +421,10 @@ static int php_stream_temp_close(php_stream *stream, int close_handle TSRMLS_DC)
zval_ptr_dtor(&ts->meta);
}
+ if (ts->tmpdir) {
+ efree(ts->tmpdir);
+ }
+
efree(ts);
return ret;
@@ -547,8 +552,8 @@ PHPAPI php_stream_ops php_stream_temp_ops = {
/* }}} */
-/* {{{ _php_stream_temp_create */
-PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC TSRMLS_DC)
+/* {{{ _php_stream_temp_create_ex */
+PHPAPI php_stream *_php_stream_temp_create_ex(int mode, size_t max_memory_usage, const char *tmpdir STREAMS_DC TSRMLS_DC)
{
php_stream_temp_data *self;
php_stream *stream;
@@ -556,7 +561,9 @@ PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STR
self = ecalloc(1, sizeof(*self));
self->smax = max_memory_usage;
self->mode = mode;
- self->meta = NULL;
+ if (tmpdir) {
+ self->tmpdir = estrdup(tmpdir);
+ }
stream = php_stream_alloc_rel(&php_stream_temp_ops, self, 0, mode & TEMP_STREAM_READONLY ? "rb" : "w+b");
stream->flags |= PHP_STREAM_FLAG_NO_BUFFER;
self->innerstream = php_stream_memory_create_rel(mode);
@@ -566,6 +573,12 @@ PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STR
}
/* }}} */
+/* {{{ _php_stream_temp_create */
+PHPAPI php_stream *_php_stream_temp_create(int mode, size_t max_memory_usage STREAMS_DC TSRMLS_DC)
+{
+ return php_stream_temp_create_ex(mode, max_memory_usage, NULL);
+}
+/* }}} */
/* {{{ _php_stream_temp_open */
PHPAPI php_stream *_php_stream_temp_open(int mode, size_t max_memory_usage, char *buf, size_t length STREAMS_DC TSRMLS_DC)