diff options
author | Ilia Alshanetsky <iliaa@php.net> | 2009-09-30 02:34:17 +0000 |
---|---|---|
committer | Ilia Alshanetsky <iliaa@php.net> | 2009-09-30 02:34:17 +0000 |
commit | dd8842c28f19e795566a40cb5d7bb0ae3003bc2e (patch) | |
tree | 8a673e6d47c30fb6dc823f20895660100334fe4b | |
parent | 1e0743df12537d80180bfa322bcc44989801bab6 (diff) | |
download | php-git-dd8842c28f19e795566a40cb5d7bb0ae3003bc2e.tar.gz |
Fixed bug #49517 (cURL's CURLOPT_FILE prevents file from being deleted after fclose).
-rw-r--r-- | ext/curl/interface.c | 31 | ||||
-rw-r--r-- | ext/curl/php_curl.h | 2 |
2 files changed, 30 insertions, 3 deletions
diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 61b7c64586..ce456dbca9 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1527,10 +1527,22 @@ PHP_FUNCTION(curl_copy_handle) dupch->cp = cp; dupch->uses = 0; + if (ch->handlers->write->stream) { + Z_ADDREF_P(dupch->handlers->write->stream); + dupch->handlers->write->stream = ch->handlers->write->stream; + } dupch->handlers->write->method = ch->handlers->write->method; dupch->handlers->write->type = ch->handlers->write->type; + if (ch->handlers->read->stream) { + Z_ADDREF_P(ch->handlers->read->stream); + } + dupch->handlers->read->stream = ch->handlers->read->stream; dupch->handlers->read->method = ch->handlers->read->method; dupch->handlers->write_header->method = ch->handlers->write_header->method; + if (ch->handlers->write_header->stream) { + Z_ADDREF_P(ch->handlers->write_header->stream); + } + dupch->handlers->write_header->stream = ch->handlers->write_header->stream; dupch->handlers->write->fp = ch->handlers->write->fp; dupch->handlers->write_header->fp = ch->handlers->write_header->fp; @@ -1785,9 +1797,10 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu switch (option) { case CURLOPT_FILE: if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') { - zend_list_addref(Z_LVAL_PP(zvalue)); + Z_ADDREF_PP(zvalue); ch->handlers->write->fp = fp; ch->handlers->write->method = PHP_CURL_FILE; + ch->handlers->write->stream = *zvalue; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "the provided file handle is not writable"); RETVAL_FALSE; @@ -1796,9 +1809,10 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu break; case CURLOPT_WRITEHEADER: if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') { - zend_list_addref(Z_LVAL_PP(zvalue)); + Z_ADDREF_PP(zvalue); ch->handlers->write_header->fp = fp; ch->handlers->write_header->method = PHP_CURL_FILE; + ch->handlers->write_header->stream = *zvalue; } else { php_error_docref(NULL TSRMLS_CC, E_WARNING, "the provided file handle is not writable"); RETVAL_FALSE; @@ -1806,9 +1820,10 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu } break; case CURLOPT_INFILE: - zend_list_addref(Z_LVAL_PP(zvalue)); + Z_ADDREF_PP(zvalue); ch->handlers->read->fp = fp; ch->handlers->read->fd = Z_LVAL_PP(zvalue); + ch->handlers->read->stream = *zvalue; break; case CURLOPT_STDERR: if (((php_stream *) what)->mode[0] != 'r' || ((php_stream *) what)->mode[1] == '+') { @@ -2545,6 +2560,16 @@ static void _php_curl_close_ex(php_curl *ch TSRMLS_DC) efree(ch->header.str); } + if (ch->handlers->write_header->stream) { + zval_ptr_dtor(&ch->handlers->write_header->stream); + } + if (ch->handlers->write->stream) { + zval_ptr_dtor(&ch->handlers->write->stream); + } + if (ch->handlers->read->stream) { + zval_ptr_dtor(&ch->handlers->read->stream); + } + efree(ch->handlers->write); efree(ch->handlers->write_header); efree(ch->handlers->read); diff --git a/ext/curl/php_curl.h b/ext/curl/php_curl.h index 3063d8b42d..0e4d81c456 100644 --- a/ext/curl/php_curl.h +++ b/ext/curl/php_curl.h @@ -86,6 +86,7 @@ typedef struct { smart_str buf; int method; int type; + zval *stream; } php_curl_write; typedef struct { @@ -94,6 +95,7 @@ typedef struct { FILE *fp; long fd; int method; + zval *stream; } php_curl_read; typedef struct { |