Skip to content

Commit

Permalink
Merge branch 'master' of git.php.net:/php-src
Browse files Browse the repository at this point in the history
* 'master' of git.php.net:/php-src:
  Change PHP_OS_FAMILY to "Darwin" instead of "Mac" for Darwin based systems (as suggested by Davey)
  Fixed bug #74679 (Incorrect conversion array with WSDL_CACHE_MEMORY)
  Use "Mac" instead of "OSX" to identify macOS in PHP_OS_FAMILY
  Avoid run-time checks performed at compile-time.
  Fixed performance degradaton introduced in f6ac96b
  NEWS
  NEWS
  Fix bug #74705 for collator_get_sort_key
  Fixes bug #74705 Wrong ReflectionInfo for Collator::getSortKey()
  NEWS
  NEWS
  Fixes bug #74708 reflection signatures for random_bytes+random_int
  • Loading branch information
laruence committed Jun 14, 2017
2 parents dc098b0 + a251d9b commit 3e6c0b7
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 33 deletions.
3 changes: 2 additions & 1 deletion Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -6520,7 +6520,8 @@ ZEND_VM_C_LABEL(isset_str_offset):
ZVAL_DEREF(offset);
}
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
|| (OP2_TYPE != IS_CONST
&& Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
lval = zval_get_long(offset);
ZEND_VM_C_GOTO(isset_str_offset);
Expand Down
27 changes: 18 additions & 9 deletions Zend/zend_vm_execute.h
Original file line number Diff line number Diff line change
Expand Up @@ -6180,7 +6180,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CON
ZVAL_DEREF(offset);
}
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
|| (IS_CONST != IS_CONST
&& Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
lval = zval_get_long(offset);
goto isset_str_offset;
Expand Down Expand Up @@ -10055,7 +10056,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CON
ZVAL_DEREF(offset);
}
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
|| (IS_CV != IS_CONST
&& Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
lval = zval_get_long(offset);
goto isset_str_offset;
Expand Down Expand Up @@ -11989,7 +11991,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CON
ZVAL_DEREF(offset);
}
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
|| ((IS_TMP_VAR|IS_VAR) != IS_CONST
&& Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
lval = zval_get_long(offset);
goto isset_str_offset;
Expand Down Expand Up @@ -38401,7 +38404,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_
ZVAL_DEREF(offset);
}
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
|| (IS_CONST != IS_CONST
&& Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
lval = zval_get_long(offset);
goto isset_str_offset;
Expand Down Expand Up @@ -44735,7 +44739,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_
ZVAL_DEREF(offset);
}
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
|| (IS_CV != IS_CONST
&& Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
lval = zval_get_long(offset);
goto isset_str_offset;
Expand Down Expand Up @@ -48285,7 +48290,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_CV_
ZVAL_DEREF(offset);
}
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
|| ((IS_TMP_VAR|IS_VAR) != IS_CONST
&& Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
lval = zval_get_long(offset);
goto isset_str_offset;
Expand Down Expand Up @@ -50327,7 +50333,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP
ZVAL_DEREF(offset);
}
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
|| (IS_CONST != IS_CONST
&& Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
lval = zval_get_long(offset);
goto isset_str_offset;
Expand Down Expand Up @@ -52522,7 +52529,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP
ZVAL_DEREF(offset);
}
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
|| (IS_CV != IS_CONST
&& Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
lval = zval_get_long(offset);
goto isset_str_offset;
Expand Down Expand Up @@ -53817,7 +53825,8 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC_TMP
ZVAL_DEREF(offset);
}
if (Z_TYPE_P(offset) < IS_STRING /* simple scalar types */
|| (Z_TYPE_P(offset) == IS_STRING /* or numeric string */
|| ((IS_TMP_VAR|IS_VAR) != IS_CONST
&& Z_TYPE_P(offset) == IS_STRING /* or numeric string */
&& IS_LONG == is_numeric_string(Z_STRVAL_P(offset), Z_STRLEN_P(offset), NULL, NULL, 0))) {
lval = zval_get_long(offset);
goto isset_str_offset;
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/collator/collator_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ zend_function_entry Collator_class_functions[] = {
PHP_NAMED_FE( getLocale, ZEND_FN( collator_get_locale ), collator_1_arg )
PHP_NAMED_FE( getErrorCode, ZEND_FN( collator_get_error_code ), collator_0_args )
PHP_NAMED_FE( getErrorMessage, ZEND_FN( collator_get_error_message ), collator_0_args )
PHP_NAMED_FE( getSortKey, ZEND_FN( collator_get_sort_key ), collator_2_args )
PHP_NAMED_FE( getSortKey, ZEND_FN( collator_get_sort_key ), collator_1_arg )
PHP_FE_END
};
/* }}} */
Expand Down
2 changes: 1 addition & 1 deletion ext/intl/php_intl.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ zend_function_entry intl_functions[] = {
PHP_FE( collator_get_locale, collator_1_arg )
PHP_FE( collator_get_error_code, collator_0_args )
PHP_FE( collator_get_error_message, collator_0_args )
PHP_FE( collator_get_sort_key, collator_2_args )
PHP_FE( collator_get_sort_key, collator_1_arg )

/* formatter functions */
PHP_FE( numfmt_create, arginfo_numfmt_create )
Expand Down
21 changes: 21 additions & 0 deletions ext/intl/tests/bug74705.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
Bug #74705 Wrong reflection on Collator::getSortKey
--SKIPIF--
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
--FILE--
<?php
$rm = new ReflectionMethod(Collator::class, 'getSortKey');
var_dump($rm->getNumberOfParameters());
var_dump($rm->getNumberOfRequiredParameters());

$rf = new ReflectionFunction('collator_get_sort_key');
var_dump($rf->getNumberOfParameters());
var_dump($rf->getNumberOfRequiredParameters());
?>
===DONE===
--EXPECT--
int(1)
int(1)
int(2)
int(2)
===DONE===
40 changes: 23 additions & 17 deletions ext/json/json_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static int php_json_escape_string(
{
int status;
unsigned int us;
size_t prev_pos, pos, checkpoint;
size_t pos, checkpoint;

if (len == 0) {
smart_str_appendl(buf, "\"\"", 2);
Expand Down Expand Up @@ -283,27 +283,31 @@ static int php_json_escape_string(
smart_str_appendc(buf, '"');

do {
prev_pos = pos;
us = php_next_utf8_char((unsigned char *)s, len, &pos, &status);
/* check whether UTF8 character is correct */
if (status != SUCCESS) {
if (buf->s) {
ZSTR_LEN(buf->s) = checkpoint;
}
encoder->error_code = PHP_JSON_ERROR_UTF8;
if (options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR) {
smart_str_appendl(buf, "null", 4);
us = (unsigned char)s[pos];
if (us >= 0x80) {
size_t prev_pos = pos;

us = php_next_utf8_char((unsigned char *)s, len, &pos, &status);

/* check whether UTF8 character is correct */
if (status != SUCCESS) {
if (buf->s) {
ZSTR_LEN(buf->s) = checkpoint;
}
encoder->error_code = PHP_JSON_ERROR_UTF8;
if (options & PHP_JSON_PARTIAL_OUTPUT_ON_ERROR) {
smart_str_appendl(buf, "null", 4);
}
return FAILURE;
}
return FAILURE;
}
if (us >= 0x80 && (!(options & PHP_JSON_UNESCAPED_UNICODE) || (unsigned char)s[prev_pos] == 0xE2)) {

/* Escape U+2028/U+2029 line terminators, UNLESS both
JSON_UNESCAPED_UNICODE and
JSON_UNESCAPED_LINE_TERMINATORS were provided */
if ((options & PHP_JSON_UNESCAPED_UNICODE)
&& ((options & PHP_JSON_UNESCAPED_LINE_TERMINATORS)
&& ((options & PHP_JSON_UNESCAPED_LINE_TERMINATORS)
|| us < 0x2028 || us > 0x2029)) {
smart_str_appendl(buf, &s[prev_pos], 3);
smart_str_appendl(buf, s + prev_pos, pos - prev_pos);
continue;
}
/* From http://en.wikipedia.org/wiki/UTF16 */
Expand All @@ -325,6 +329,8 @@ static int php_json_escape_string(
smart_str_appendc(buf, digits[(us & 0xf0) >> 4]);
smart_str_appendc(buf, digits[(us & 0xf)]);
} else {
pos++;

switch (us) {
case '"':
if (options & PHP_JSON_HEX_QUOT) {
Expand Down Expand Up @@ -400,7 +406,7 @@ static int php_json_escape_string(

default:
if (us >= ' ') {
smart_str_appendl(buf, s + prev_pos, pos - prev_pos);
smart_str_appendc(buf, (unsigned char) us);
} else {
smart_str_appendl(buf, "\\u00", sizeof("\\u00")-1);
smart_str_appendc(buf, digits[(us & 0xf0) >> 4]);
Expand Down
2 changes: 1 addition & 1 deletion ext/soap/php_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2623,7 +2623,7 @@ static sdlAttributePtr make_persistent_sdl_attribute(sdlAttributePtr attr, HashT
pattr->extraAttributes = malloc(sizeof(HashTable));
zend_hash_init(pattr->extraAttributes, zend_hash_num_elements(attr->extraAttributes), NULL, delete_extra_attribute_persistent, 1);

ZEND_HASH_FOREACH_STR_KEY_PTR(pattr->extraAttributes, key, tmp) {
ZEND_HASH_FOREACH_STR_KEY_PTR(attr->extraAttributes, key, tmp) {
if (key) {
pextra = malloc(sizeof(sdlExtraAttribute));
memset(pextra, 0, sizeof(sdlExtraAttribute));
Expand Down
4 changes: 2 additions & 2 deletions ext/standard/basic_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -1899,11 +1899,11 @@ ZEND_BEGIN_ARG_INFO(arginfo_mt_getrandmax, 0)
ZEND_END_ARG_INFO()
/* }}} */
/* {{{ random.c */
ZEND_BEGIN_ARG_INFO_EX(arginfo_random_bytes, 0, 0, 0)
ZEND_BEGIN_ARG_INFO_EX(arginfo_random_bytes, 0, 0, 1)
ZEND_ARG_INFO(0, length)
ZEND_END_ARG_INFO()

ZEND_BEGIN_ARG_INFO_EX(arginfo_random_int, 0, 0, 0)
ZEND_BEGIN_ARG_INFO_EX(arginfo_random_int, 0, 0, 2)
ZEND_ARG_INFO(0, min)
ZEND_ARG_INFO(0, max)
ZEND_END_ARG_INFO()
Expand Down
19 changes: 19 additions & 0 deletions ext/standard/tests/random/reflection.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
Bug #74708 Wrong reflection on random_bytes and random_int
--FILE--
<?php
$rf = new ReflectionFunction('random_bytes');
var_dump($rf->getNumberOfParameters());
var_dump($rf->getNumberOfRequiredParameters());

$rf = new ReflectionFunction('random_int');
var_dump($rf->getNumberOfParameters());
var_dump($rf->getNumberOfRequiredParameters());
?>
===DONE===
--EXPECT--
int(1)
int(1)
int(2)
int(2)
===DONE===
2 changes: 1 addition & 1 deletion main/php.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#elif defined(BSD) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
# define PHP_OS_FAMILY "BSD"
#elif defined(__APPLE__) || defined(__MACH__)
# define PHP_OS_FAMILY "OSX"
# define PHP_OS_FAMILY "Darwin"
#elif defined(__sun__)
# define PHP_OS_FAMILY "Solaris"
#elif defined(__linux__)
Expand Down

0 comments on commit 3e6c0b7

Please sign in to comment.