summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/standard/file.c5
-rw-r--r--ext/standard/http_fopen_wrapper.c5
-rwxr-xr-xmain/php_streams.h2
-rwxr-xr-xmain/streams.c13
4 files changed, 12 insertions, 13 deletions
diff --git a/ext/standard/file.c b/ext/standard/file.c
index 75bc7d8633..2332f1423d 100644
--- a/ext/standard/file.c
+++ b/ext/standard/file.c
@@ -732,6 +732,7 @@ PHP_FUNCTION(stream_context_get_options)
array_init(return_value);
*return_value = *context->options;
zval_copy_ctor(return_value);
+
}
/* }}} */
@@ -766,7 +767,6 @@ PHP_FUNCTION(stream_context_set_option)
php_stream_context_set_option(context, wrappername, optionname, zvalue);
RETVAL_TRUE;
}
-
}
/* }}} */
@@ -867,8 +867,7 @@ PHP_NAMED_FUNCTION(php_if_fopen)
RETURN_FALSE;
}
if (zcontext) {
- context = (php_stream_context*)zend_fetch_resource(&zcontext TSRMLS_CC, -1, "Stream-Context", NULL, 1, le_stream_context);
- ZEND_VERIFY_RESOURCE(context);
+ ZEND_FETCH_RESOURCE(context, php_stream_context*, &zcontext, -1, "stream-context", le_stream_context);
}
stream = php_stream_open_wrapper_ex(filename, mode,
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index e0a817a6d5..361c79b50e 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -91,7 +91,7 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, ch
char *scratch = NULL;
char *tmp = NULL;
char *ua_str = NULL;
- zval **ua_zval;
+ zval **ua_zval = NULL;
int scratch_len = 0;
int body = 0;
char location[HTTP_HEADER_BLOCK_SIZE];
@@ -201,8 +201,7 @@ php_stream *php_stream_url_wrap_http(php_stream_wrapper *wrapper, char *path, ch
php_stream_write(stream, scratch, strlen(scratch));
if (context &&
- php_stream_context_get_option(context, "http", "user_agent", (zval **) &ua_zval) == FAILURE &&
- php_stream_context_get_option(context, "https", "user_agent", (zval **) &ua_zval) == FAILURE) {
+ php_stream_context_get_option(context, "http", "user_agent", &ua_zval) == SUCCESS) {
ua_str = Z_STRVAL_PP(ua_zval);
} else if (BG(user_agent)) {
ua_str = BG(user_agent);
diff --git a/main/php_streams.h b/main/php_streams.h
index 0bbd9d954e..fa57b5aff3 100755
--- a/main/php_streams.h
+++ b/main/php_streams.h
@@ -490,7 +490,7 @@ PHPAPI extern php_stream_ops php_stream_userspace_ops;
PHPAPI void php_stream_context_free(php_stream_context *context);
PHPAPI php_stream_context *php_stream_context_alloc(void);
PHPAPI int php_stream_context_get_option(php_stream_context *context,
- const char *wrappername, const char *optionname, zval **optionvalue);
+ const char *wrappername, const char *optionname, zval ***optionvalue);
PHPAPI int php_stream_context_set_option(php_stream_context *context,
const char *wrappername, const char *optionname, zval *optionvalue);
diff --git a/main/streams.c b/main/streams.c
index dd6b24b4fc..26462c6f42 100755
--- a/main/streams.c
+++ b/main/streams.c
@@ -1829,29 +1829,30 @@ PHPAPI void php_stream_notification_free(php_stream_notifier *notifier)
}
PHPAPI int php_stream_context_get_option(php_stream_context *context,
- const char *wrappername, const char *optionname, zval **optionvalue)
+ const char *wrappername, const char *optionname, zval ***optionvalue)
{
zval **wrapperhash;
if (FAILURE == zend_hash_find(Z_ARRVAL_P(context->options), (char*)wrappername, strlen(wrappername)+1, (void**)&wrapperhash))
return FAILURE;
-
- return zend_hash_find(Z_ARRVAL_PP(wrapperhash), (char*)optionname, strlen(optionname)+1, (void**)&optionvalue);
+ return zend_hash_find(Z_ARRVAL_PP(wrapperhash), (char*)optionname, strlen(optionname)+1, (void**)optionvalue);
}
PHPAPI int php_stream_context_set_option(php_stream_context *context,
const char *wrappername, const char *optionname, zval *optionvalue)
{
zval **wrapperhash;
+ zval *category;
if (FAILURE == zend_hash_find(Z_ARRVAL_P(context->options), (char*)wrappername, strlen(wrappername)+1, (void**)&wrapperhash)) {
- MAKE_STD_ZVAL(*wrapperhash);
- array_init(*wrapperhash);
- if (FAILURE == zend_hash_update(Z_ARRVAL_P(context->options), (char*)wrappername, strlen(wrappername)+1, (void**)wrapperhash, sizeof(zval *), NULL))
+ MAKE_STD_ZVAL(category);
+ array_init(category);
+ if (FAILURE == zend_hash_update(Z_ARRVAL_P(context->options), (char*)wrappername, strlen(wrappername)+1, (void**)&category, sizeof(zval *), NULL))
return FAILURE;
ZVAL_ADDREF(optionvalue);
+ wrapperhash = &category;
}
return zend_hash_update(Z_ARRVAL_PP(wrapperhash), (char*)optionname, strlen(optionname)+1, (void**)&optionvalue, sizeof(zval *), NULL);
}