Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ext/curl: Use stream helper macro to retrieve stream #18077

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
@@ -149,7 +149,7 @@ void _php_curl_verify_handlers(php_curl *ch, bool reporterror) /* {{{ */
ZEND_ASSERT(ch);

if (!Z_ISUNDEF(ch->handlers.std_err)) {
stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers.std_err, NULL, php_file_le_stream(), php_file_le_pstream());
php_stream_from_zval_no_verify(stream, &ch->handlers.std_err);
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_STDERR resource has gone away, resetting to stderr");
@@ -161,7 +161,7 @@ void _php_curl_verify_handlers(php_curl *ch, bool reporterror) /* {{{ */
}
}
if (ch->handlers.read && !Z_ISUNDEF(ch->handlers.read->stream)) {
stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers.read->stream, NULL, php_file_le_stream(), php_file_le_pstream());
php_stream_from_zval_no_verify(stream, &ch->handlers.read->stream);
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_INFILE resource has gone away, resetting to default");
@@ -175,7 +175,7 @@ void _php_curl_verify_handlers(php_curl *ch, bool reporterror) /* {{{ */
}
}
if (ch->handlers.write_header && !Z_ISUNDEF(ch->handlers.write_header->stream)) {
stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers.write_header->stream, NULL, php_file_le_stream(), php_file_le_pstream());
php_stream_from_zval_no_verify(stream, &ch->handlers.write_header->stream);
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_WRITEHEADER resource has gone away, resetting to default");
@@ -189,7 +189,7 @@ void _php_curl_verify_handlers(php_curl *ch, bool reporterror) /* {{{ */
}
}
if (ch->handlers.write && !Z_ISUNDEF(ch->handlers.write->stream)) {
stream = (php_stream *)zend_fetch_resource2_ex(&ch->handlers.write->stream, NULL, php_file_le_stream(), php_file_le_pstream());
php_stream_from_zval_no_verify(stream, &ch->handlers.write->stream);
if (stream == NULL) {
if (reporterror) {
php_error_docref(NULL, E_WARNING, "CURLOPT_FILE resource has gone away, resetting to default");
@@ -2035,7 +2035,7 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
php_stream *what = NULL;

if (Z_TYPE_P(zvalue) != IS_NULL) {
what = (php_stream *)zend_fetch_resource2_ex(zvalue, "File-Handle", php_file_le_stream(), php_file_le_pstream());
php_stream_from_zval_no_verify(what, zvalue);
if (!what) {
return FAILURE;
}
@@ -2466,7 +2466,7 @@ PHP_FUNCTION(curl_exec)

if (!Z_ISUNDEF(ch->handlers.std_err)) {
php_stream *stream;
stream = (php_stream*)zend_fetch_resource2_ex(&ch->handlers.std_err, NULL, php_file_le_stream(), php_file_le_pstream());
php_stream_from_zval_no_verify(stream, &ch->handlers.std_err);
if (stream) {
php_stream_flush(stream);
}
4 changes: 2 additions & 2 deletions main/php_streams.h
Original file line number Diff line number Diff line change
@@ -282,8 +282,8 @@ END_EXTERN_C()
return; \
} \
} while (0)
#define php_stream_from_res_no_verify(xstr, pzval) (xstr) = (php_stream*)zend_fetch_resource2((res), "stream", php_file_le_stream(), php_file_le_pstream())
#define php_stream_from_zval_no_verify(xstr, pzval) (xstr) = (php_stream*)zend_fetch_resource2_ex((pzval), "stream", php_file_le_stream(), php_file_le_pstream())
#define php_stream_from_res_no_verify(xstr, pzval) (xstr) = (php_stream*)zend_fetch_resource2((res), NULL, php_file_le_stream(), php_file_le_pstream())
#define php_stream_from_zval_no_verify(xstr, pzval) (xstr) = (php_stream*)zend_fetch_resource2_ex((pzval), NULL, php_file_le_stream(), php_file_le_pstream())

BEGIN_EXTERN_C()

Loading
Oops, something went wrong.