diff options
author | Gustavo André dos Santos Lopes <cataphract@php.net> | 2011-09-04 22:36:33 +0000 |
---|---|---|
committer | Gustavo André dos Santos Lopes <cataphract@php.net> | 2011-09-04 22:36:33 +0000 |
commit | 2acbe4c93ed3472eb9ccf01003562bc899667688 (patch) | |
tree | d11aa0e65afca52d43246f162e063f2b944df205 /main/streams | |
parent | 10f68a92caeb498c0a2242794b249bde9dc1a647 (diff) | |
download | php-git-2acbe4c93ed3472eb9ccf01003562bc899667688.tar.gz |
- Fixed borked refactoring in r307437 (using SUCCESS/FAILURE return instead of
out parameter).
- Fixed signature of php_stream_copy_to_stream_ex to return int in 5.4/trunk
instead of size_t, as the function only returns SUCCESS/FAILURE.
Diffstat (limited to 'main/streams')
-rw-r--r-- | main/streams/cast.c | 14 | ||||
-rwxr-xr-x | main/streams/streams.c | 2 |
2 files changed, 9 insertions, 7 deletions
diff --git a/main/streams/cast.c b/main/streams/cast.c index 38eb1a987c..305ee6e8aa 100644 --- a/main/streams/cast.c +++ b/main/streams/cast.c @@ -271,15 +271,15 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show newstream = php_stream_fopen_tmpfile(); if (newstream) { - size_t retval = php_stream_copy_to_stream_ex(stream, newstream, PHP_STREAM_COPY_ALL, NULL); + int retcopy = php_stream_copy_to_stream_ex(stream, newstream, PHP_STREAM_COPY_ALL, NULL); - if (ret != SUCCESS) { + if (retcopy != SUCCESS) { php_stream_close(newstream); } else { - int retcode = php_stream_cast(newstream, castas | flags, (void **)ret, show_err); + int retcast = php_stream_cast(newstream, castas | flags, (void **)ret, show_err); - if (retcode == SUCCESS) { - rewind(*(FILE**)retval); + if (retcast == SUCCESS) { + rewind(*(FILE**)ret); } /* do some specialized cleanup */ @@ -287,7 +287,9 @@ PHPAPI int _php_stream_cast(php_stream *stream, int castas, void **ret, int show php_stream_free(stream, PHP_STREAM_FREE_CLOSE_CASTED); } - return retcode; + /* TODO: we probably should be setting .stdiocast and .fclose_stdiocast or + * we may be leaking the FILE*. Needs investigation, though. */ + return retcast; } } } diff --git a/main/streams/streams.c b/main/streams/streams.c index 15c1454547..4679a97aa6 100755 --- a/main/streams/streams.c +++ b/main/streams/streams.c @@ -1417,7 +1417,7 @@ PHPAPI size_t _php_stream_copy_to_mem(php_stream *src, char **buf, size_t maxlen } /* Returns SUCCESS/FAILURE and sets *len to the number of bytes moved */ -PHPAPI size_t _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest, size_t maxlen, size_t *len STREAMS_DC TSRMLS_DC) +PHPAPI int _php_stream_copy_to_stream_ex(php_stream *src, php_stream *dest, size_t maxlen, size_t *len STREAMS_DC TSRMLS_DC) { char buf[CHUNK_SIZE]; size_t readchunk; |