Skip to content

Commit e7f4e61

Browse files
committed
uri: Always use const pointers when referring to uri_parser_t
The actual parser definitions are all `const` and must never be modified. Make sure to always use `const` pointers.
1 parent b27d919 commit e7f4e61

File tree

10 files changed

+13
-13
lines changed

10 files changed

+13
-13
lines changed

ext/filter/logical_filters.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ zend_result php_filter_validate_url(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
612612
int parser_name_set;
613613
FETCH_STR_OPTION(parser_name, URL_OPTION_URI_PARSER_CLASS);
614614

615-
uri_parser_t *uri_parser = php_uri_get_parser(parser_name_set ? parser_name : NULL);
615+
const uri_parser_t *uri_parser = php_uri_get_parser(parser_name_set ? parser_name : NULL);
616616
if (uri_parser == NULL) {
617617
zend_value_error("%s(): \"uri_parser_class\" option has invalid value", get_active_function_name());
618618
RETURN_VALIDATION_FAILED

ext/openssl/xp_ssl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2634,7 +2634,7 @@ static char *php_openssl_get_url_name(const char *resourcename,
26342634
return NULL;
26352635
}
26362636

2637-
uri_parser_t *uri_parser = php_stream_context_get_uri_parser("ssl", context);
2637+
const uri_parser_t *uri_parser = php_stream_context_get_uri_parser("ssl", context);
26382638
if (uri_parser == NULL) {
26392639
zend_value_error("%s(): Provided stream context has invalid value for the \"uri_parser_class\" option", get_active_function_name());
26402640
return NULL;

ext/soap/php_http.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ int make_http_soap_request(
431431
}
432432

433433
if (location != NULL && ZSTR_VAL(location)[0] != '\000') {
434-
uri_parser_t *uri_parser = php_uri_get_parser(uri_parser_class);
434+
const uri_parser_t *uri_parser = php_uri_get_parser(uri_parser_class);
435435
if (uri_parser == NULL) {
436436
zend_argument_value_error(6, "must be a valid URI parser name");
437437
return FALSE;
@@ -1148,7 +1148,7 @@ int make_http_soap_request(
11481148
char *loc;
11491149

11501150
if ((loc = get_http_header_value(ZSTR_VAL(http_headers), "Location:")) != NULL) {
1151-
uri_parser_t *uri_parser = php_uri_get_parser(uri_parser_class);
1151+
const uri_parser_t *uri_parser = php_uri_get_parser(uri_parser_class);
11521152
if (uri_parser == NULL) {
11531153
efree(loc);
11541154
zend_argument_value_error(6, "must be a valid URI parser name");

ext/standard/ftp_fopen_wrapper.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ static php_stream *php_ftp_fopen_connect(php_stream_wrapper *wrapper, const char
135135
char *transport;
136136
int transport_len;
137137

138-
uri_parser_t *uri_parser = php_stream_context_get_uri_parser("ftp", context);
138+
const uri_parser_t *uri_parser = php_stream_context_get_uri_parser("ftp", context);
139139
if (uri_parser == NULL) {
140140
zend_value_error("%s(): Provided stream context has invalid value for the \"uri_parser_class\" option", get_active_function_name());
141141
return NULL;
@@ -956,7 +956,7 @@ static int php_stream_ftp_rename(php_stream_wrapper *wrapper, const char *url_fr
956956
int result;
957957
char tmp_line[512];
958958

959-
uri_parser_t *uri_parser = php_stream_context_get_uri_parser("ftp", context);
959+
const uri_parser_t *uri_parser = php_stream_context_get_uri_parser("ftp", context);
960960
if (uri_parser == NULL) {
961961
zend_value_error("%s(): Provided stream context has invalid value for the \"uri_parser_class\" option", get_active_function_name());
962962
return 0;

ext/standard/http_fopen_wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
393393
return NULL;
394394
}
395395

396-
uri_parser_t *uri_parser = php_stream_context_get_uri_parser("http", context);
396+
const uri_parser_t *uri_parser = php_stream_context_get_uri_parser("http", context);
397397
if (uri_parser == NULL) {
398398
zend_value_error("%s(): Provided stream context has invalid value for the \"uri_parser_class\" option", get_active_function_name());
399399
return NULL;

ext/uri/php_uri.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static const zend_module_dep uri_deps[] = {
5252

5353
static zend_array uri_parsers;
5454

55-
static uri_parser_t *uri_parser_by_name(const char *uri_parser_name, size_t uri_parser_name_len)
55+
static const uri_parser_t *uri_parser_by_name(const char *uri_parser_name, size_t uri_parser_name_len)
5656
{
5757
return zend_hash_str_find_ptr(&uri_parsers, uri_parser_name, uri_parser_name_len);
5858
}
@@ -107,7 +107,7 @@ static HashTable *uri_get_debug_properties(zend_object *object)
107107
return result;
108108
}
109109

110-
PHPAPI uri_parser_t *php_uri_get_parser(const zend_string *uri_parser_name)
110+
PHPAPI const uri_parser_t *php_uri_get_parser(const zend_string *uri_parser_name)
111111
{
112112
if (uri_parser_name == NULL) {
113113
return uri_parser_by_name(PHP_URI_PARSER_PHP_PARSE_URL, sizeof(PHP_URI_PARSER_PHP_PARSE_URL) - 1);

ext/uri/php_uri.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ PHPAPI zend_result php_uri_parser_register(const uri_parser_t *uri_parser);
4747
* @param uri_parser_name The URI parser name
4848
* @return The URI parser
4949
*/
50-
PHPAPI uri_parser_t *php_uri_get_parser(const zend_string *uri_parser_name);
50+
PHPAPI const uri_parser_t *php_uri_get_parser(const zend_string *uri_parser_name);
5151

5252
ZEND_ATTRIBUTE_NONNULL PHPAPI uri_internal_t *php_uri_parse(const uri_parser_t *uri_parser, const char *uri_str, size_t uri_str_len, bool silent);
5353

ext/zend_test/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ static ZEND_FUNCTION(zend_test_uri_parser)
735735
Z_PARAM_STR(parser_name)
736736
ZEND_PARSE_PARAMETERS_END();
737737

738-
uri_parser_t *parser = php_uri_get_parser(parser_name);
738+
const uri_parser_t *parser = php_uri_get_parser(parser_name);
739739
if (parser == NULL) {
740740
zend_argument_value_error(1, "Unknown parser");
741741
RETURN_THROWS();

main/streams/php_stream_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ void php_stream_context_unset_option(php_stream_context *context,
6868

6969
struct uri_parser_t;
7070

71-
PHPAPI struct uri_parser_t *php_stream_context_get_uri_parser(const char *wrappername, php_stream_context *context);
71+
PHPAPI const struct uri_parser_t *php_stream_context_get_uri_parser(const char *wrappername, php_stream_context *context);
7272
PHPAPI php_stream_notifier *php_stream_notification_alloc(void);
7373
PHPAPI void php_stream_notification_free(php_stream_notifier *notifier);
7474
END_EXTERN_C()

main/streams/streams.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2458,7 +2458,7 @@ void php_stream_context_unset_option(php_stream_context *context,
24582458
}
24592459
/* }}} */
24602460

2461-
PHPAPI struct uri_parser_t *php_stream_context_get_uri_parser(const char *wrappername, php_stream_context *context)
2461+
PHPAPI const struct uri_parser_t *php_stream_context_get_uri_parser(const char *wrappername, php_stream_context *context)
24622462
{
24632463
if (context == NULL) {
24642464
return php_uri_get_parser(NULL);

0 commit comments

Comments
 (0)