]> granicus.if.org Git - php/commitdiff
- Fixed borked refactoring in r307437 (using SUCCESS/FAILURE return instead of
authorGustavo André dos Santos Lopes <cataphract@php.net>
Sun, 4 Sep 2011 22:36:33 +0000 (22:36 +0000)
committerGustavo André dos Santos Lopes <cataphract@php.net>
Sun, 4 Sep 2011 22:36:33 +0000 (22:36 +0000)
  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.

main/php_streams.h
main/streams/cast.c
main/streams/streams.c

index b87cf1b86ef925f1b95bab16d31ca72330aa607f..b1d70a84015a2685711c7ad2e3e59a8f4d9d1bc3 100755 (executable)
@@ -438,7 +438,7 @@ BEGIN_EXTERN_C()
 ZEND_ATTRIBUTE_DEPRECATED
 PHPAPI size_t _php_stream_copy_to_stream(php_stream *src, php_stream *dest, size_t maxlen STREAMS_DC TSRMLS_DC);
 #define php_stream_copy_to_stream(src, dest, maxlen)   _php_stream_copy_to_stream((src), (dest), (maxlen) STREAMS_CC TSRMLS_CC)
-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);
 #define php_stream_copy_to_stream_ex(src, dest, maxlen, len)   _php_stream_copy_to_stream_ex((src), (dest), (maxlen), (len) STREAMS_CC TSRMLS_CC)
 
 
index 38eb1a987c009d8b5ab7167271ffb1845bda78c7..305ee6e8aab9803a7f4a34d6988d98231ae3353a 100644 (file)
@@ -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;
                                }
                        }
                }
index 15c1454547ac39ccfec2cec258846b38dc64c0d2..4679a97aa691cfa4917ebad2e1d65077a056edeb 100755 (executable)
@@ -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;