Skip to content

Commit 7517d38

Browse files
committed
Merge branch 'master' of https://git.php.net/push/php-src
2 parents 6129a56 + 2a2f42c commit 7517d38

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+561
-303
lines changed

NEWS

+12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3+
09 Jul 2015, PHP 7.0.0 Beta 1
4+
5+
- Core:
6+
. Fixed bug #69768 (escapeshell*() doesn't cater to !). (cmb)
7+
8+
- PCRE:
9+
. Fixed Bug #53823 (preg_replace: * qualifier on unicode replace garbles the
10+
string). (cmb)
11+
312
25 Jun 2015, PHP 7.0.0 Alpha 2
413

514
- Core:
@@ -49,6 +58,9 @@
4958
. Removed opcache.load_comments configuration directive. Now doc comments
5059
loading costs nothing and always enabled. (Dmitry)
5160
. Fixed bug #69838 (Wrong size calculation for function table). (Anatol)
61+
62+
- PCRE:
63+
. Fixed bug #69864 (Segfault in preg_replace_callback) (cmb, ab)
5264

5365
- PDO_pgsql:
5466
. Fixed bug #69752 (PDOStatement::execute() leaks memory with DML

README.RELEASE_PROCESS

+3-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@ to upgrade.
266266

267267
8. Commit all the changes to their respective git repos
268268

269-
9. Wait an hour or two, then send a mail to [email protected],
269+
9. Please note down the sha256 and the PGP signature (.asc). These *must* be
270+
included in the release mail.
271+
10. Wait an hour or two, then send a mail to [email protected],
270272
[email protected] and [email protected] with a text similar to
271273
http://news.php.net/php.internals/17222.
272274
Please make sure that the mail to php-announce@ is its own completely seperate email.

UPGRADING.INTERNALS

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ changes. See: https://wiki.php.net/phpng-upgrading
7979
g. sprintf() formats
8080

8181
New printf modifier 'p' was implemented to platform independently output zend_long,
82-
zend_ulong and php_size_t datatypes. That modifier can be used with'd', 'u', 'x' and 'o'
82+
zend_ulong and php_size_t datatypes. That modifier can be used with 'd', 'u', 'x' and 'o'
8383
printf format specs with spprintf, snprintf and the wrapping printf implementations.
8484
%pu is sufficient for both zend_ulong and php_size_t. the code using %p spec to output
8585
pointer address might need to be enclosed into #ifdef when it unlickily followed by 'd',
File renamed without changes.

Zend/tests/bug69905.phpt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #69905 (null ptr deref and segfault in ZEND_FETCH_DIM_RW_SPEC_VAR_UNUSED_HANDLER)
3+
--FILE--
4+
<?php
5+
md5(0)[]--;
6+
?>
7+
--EXPECTF--
8+
Fatal error: Uncaught Error: [] operator not supported for strings in %sbug69905.php:2
9+
Stack trace:
10+
#0 {main}
11+
thrown in %sbug69905.php on line 2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
Aborted yield during nested calls
3+
--FILE--
4+
<?php
5+
6+
function func() {}
7+
8+
function gen($x) {
9+
func(func($x, $x, func($x, yield)));
10+
}
11+
12+
$gen = gen("x");
13+
$gen->rewind();
14+
15+
?>
16+
===DONE===
17+
--EXPECT--
18+
===DONE===
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
Aborted yield during switch
3+
--FILE--
4+
<?php
5+
6+
function gen($x) {
7+
switch ($x."y") {
8+
default:
9+
yield;
10+
}
11+
}
12+
13+
$gen = gen("x");
14+
$gen->rewind();
15+
16+
?>
17+
===DONE===
18+
--EXPECT--
19+
===DONE===

Zend/zend_alloc.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ ZEND_API size_t ZEND_FASTCALL _zend_mem_block_size(void *ptr ZEND_FILE_LINE_DC Z
8484
#include "zend_alloc_sizes.h"
8585

8686
/* _emalloc() & _efree() specialization */
87-
#if !ZEND_DEBUG && !defined(_WIN32)
87+
#if !ZEND_DEBUG && defined(HAVE_BUILTIN_CONSTANT_P)
8888

8989
# define _ZEND_BIN_ALLOCATOR_DEF(_num, _size, _elements, _pages, x, y) \
9090
ZEND_API void* ZEND_FASTCALL _emalloc_ ## _size(void) ZEND_ATTRIBUTE_MALLOC;

Zend/zend_builtin_functions.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_error_reporting, 0, 0, 0)
129129
ZEND_ARG_INFO(0, new_error_level)
130130
ZEND_END_ARG_INFO()
131131

132-
ZEND_BEGIN_ARG_INFO_EX(arginfo_define, 0, 0, 3)
132+
ZEND_BEGIN_ARG_INFO_EX(arginfo_define, 0, 0, 2)
133133
ZEND_ARG_INFO(0, constant_name)
134134
ZEND_ARG_INFO(0, value)
135135
ZEND_ARG_INFO(0, case_insensitive)
@@ -600,8 +600,8 @@ ZEND_FUNCTION(strncasecmp)
600600
}
601601
/* }}} */
602602

603-
/* {{{ proto array each(array arr)
604-
Return the currently pointed key..value pair in the passed array, and advance the pointer to the next element */
603+
/* {{{ proto mixed each(array &arr)
604+
Return the currently pointed key..value pair in the passed array, and advance the pointer to the next element, or false if there is no element at this place */
605605
ZEND_FUNCTION(each)
606606
{
607607
zval *array, *entry, tmp;
@@ -775,7 +775,7 @@ static void copy_constant_array(zval *dst, zval *src) /* {{{ */
775775
}
776776
/* }}} */
777777

778-
/* {{{ proto bool define(string constant_name, mixed value, boolean case_insensitive=false)
778+
/* {{{ proto bool define(string constant_name, mixed value[, boolean case_insensitive])
779779
Define a new constant */
780780
ZEND_FUNCTION(define)
781781
{
@@ -933,8 +933,8 @@ ZEND_FUNCTION(get_called_class)
933933
}
934934
/* }}} */
935935

936-
/* {{{ proto string get_parent_class([mixed object])
937-
Retrieves the parent class name for object or class or current scope. */
936+
/* {{{ proto mixed get_parent_class([mixed object])
937+
Retrieves the parent class name for object or class or current scope or false if not in a scope. */
938938
ZEND_FUNCTION(get_parent_class)
939939
{
940940
zval *arg;
@@ -1025,15 +1025,15 @@ static void is_a_impl(INTERNAL_FUNCTION_PARAMETERS, zend_bool only_subclass) /*
10251025
}
10261026
/* }}} */
10271027

1028-
/* {{{ proto bool is_subclass_of(mixed object_or_string, string class_name [, bool allow_string=true])
1028+
/* {{{ proto bool is_subclass_of(mixed object_or_string, string class_name [, bool allow_string])
10291029
Returns true if the object has this class as one of its parents */
10301030
ZEND_FUNCTION(is_subclass_of)
10311031
{
10321032
is_a_impl(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
10331033
}
10341034
/* }}} */
10351035

1036-
/* {{{ proto bool is_a(mixed object_or_string, string class_name [, bool allow_string=false])
1036+
/* {{{ proto bool is_a(mixed object_or_string, string class_name [, bool allow_string])
10371037
Returns true if the first argument is an object and is this class or has this class as one of its parents, */
10381038
ZEND_FUNCTION(is_a)
10391039
{
@@ -1566,7 +1566,7 @@ ZEND_FUNCTION(class_alias)
15661566
/* }}} */
15671567

15681568
#if ZEND_DEBUG
1569-
/* {{{ proto void leak(int num_bytes=3)
1569+
/* {{{ proto void leak([int num_bytes])
15701570
Cause an intentional memory leak, for testing/debugging purposes */
15711571
ZEND_FUNCTION(leak)
15721572
{
@@ -1670,7 +1670,7 @@ ZEND_FUNCTION(trigger_error)
16701670
}
16711671
/* }}} */
16721672

1673-
/* {{{ proto string set_error_handler(string error_handler [, int error_types])
1673+
/* {{{ proto string set_error_handler(callable error_handler [, int error_types])
16741674
Sets a user-defined error handler function. Returns the previously defined error handler, or false on error */
16751675
ZEND_FUNCTION(set_error_handler)
16761676
{
@@ -1739,8 +1739,8 @@ ZEND_FUNCTION(restore_error_handler)
17391739
}
17401740
/* }}} */
17411741

1742-
/* {{{ proto string set_exception_handler(callable exception_handler)
1743-
Sets a user-defined exception handler function. Returns the previously defined exception handler, or false on error */
1742+
/* {{{ proto mixed set_exception_handler(callable exception_handler)
1743+
Sets a user-defined exception handler function. Returns the previously defined exception handler, or false on error */
17441744
ZEND_FUNCTION(set_exception_handler)
17451745
{
17461746
zval *exception_handler;
@@ -2115,7 +2115,7 @@ static int add_constant_info(zval *item, void *arg) /* {{{ */
21152115
}
21162116
/* }}} */
21172117

2118-
/* {{{ proto array get_loaded_extensions([bool zend_extensions]) U
2118+
/* {{{ proto array get_loaded_extensions([bool zend_extensions])
21192119
Return an array containing names of loaded extensions */
21202120
ZEND_FUNCTION(get_loaded_extensions)
21212121
{

Zend/zend_closures.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ ZEND_METHOD(Closure, __invoke) /* {{{ */
6969
}
7070
/* }}} */
7171

72-
/* {{{ proto mixed Closure::call(object $to [, mixed $parameter] [, mixed $...] )
72+
/* {{{ proto mixed Closure::call(object to [, mixed parameter] [, mixed ...] )
7373
Call closure, binding to a given object with its class as the scope */
7474
ZEND_METHOD(Closure, call)
7575
{
@@ -143,7 +143,7 @@ ZEND_METHOD(Closure, call)
143143
}
144144
/* }}} */
145145

146-
/* {{{ proto Closure Closure::bind(Closure $old, object $to [, mixed $scope = "static" ] )
146+
/* {{{ proto Closure Closure::bind(callable old, object to [, mixed scope])
147147
Create a closure from another one and bind to another object and scope */
148148
ZEND_METHOD(Closure, bind)
149149
{

Zend/zend_execute.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1682,11 +1682,11 @@ static zend_always_inline void zend_fetch_dimension_address(zval *result, zval *
16821682

16831683
if (dim == NULL) {
16841684
zend_error(E_EXCEPTION | E_ERROR, "[] operator not supported for strings");
1685+
ZVAL_NULL(result);
16851686
} else {
16861687
zend_check_string_offset(dim, type);
1688+
ZVAL_INDIRECT(result, NULL); /* wrong string offset */
16871689
}
1688-
1689-
ZVAL_INDIRECT(result, NULL); /* wrong string offset */
16901690
} else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
16911691
if (!Z_OBJ_HT_P(container)->read_dimension) {
16921692
zend_error(E_EXCEPTION | E_ERROR, "Cannot use object as array");

Zend/zend_execute.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
5858
{
5959
zend_refcounted *ref = NULL;
6060

61-
if ((value_type & (IS_VAR|IS_CV)) && Z_ISREF_P(value)) {
61+
if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && Z_ISREF_P(value)) {
6262
ref = Z_COUNTED_P(value);
6363
value = Z_REFVAL_P(value);
6464
}
@@ -78,7 +78,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
7878
Z_OBJ_HANDLER_P(variable_ptr, set)(variable_ptr, value);
7979
return variable_ptr;
8080
}
81-
if ((value_type & (IS_VAR|IS_CV)) && variable_ptr == value) {
81+
if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && variable_ptr == value) {
8282
return variable_ptr;
8383
}
8484
garbage = Z_COUNTED_P(variable_ptr);
@@ -93,7 +93,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
9393
if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
9494
Z_ADDREF_P(variable_ptr);
9595
}
96-
} else if (/* value_type == IS_VAR && */ UNEXPECTED(ref)) {
96+
} else if (ZEND_CONST_COND(value_type == IS_VAR, 1) && UNEXPECTED(ref)) {
9797
if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
9898
efree_size(ref, sizeof(zend_reference));
9999
} else if (Z_OPT_REFCOUNTED_P(variable_ptr)) {
@@ -122,7 +122,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
122122
if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
123123
Z_ADDREF_P(variable_ptr);
124124
}
125-
} else if (/* value_type == IS_VAR && */ UNEXPECTED(ref)) {
125+
} else if (ZEND_CONST_COND(value_type == IS_VAR, 1) && UNEXPECTED(ref)) {
126126
if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
127127
efree_size(ref, sizeof(zend_reference));
128128
} else if (Z_OPT_REFCOUNTED_P(variable_ptr)) {

Zend/zend_generators.c

+7-6
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ static zend_object *zend_generator_create(zend_class_entry *class_type);
3434
static void zend_generator_cleanup_unfinished_execution(zend_generator *generator) /* {{{ */
3535
{
3636
zend_execute_data *execute_data = generator->execute_data;
37-
/* -1 required because we want the last run opcode, not the next to-be-run one. */
38-
uint32_t op_num = execute_data->opline - execute_data->func->op_array.opcodes - 1;
3937

4038
if (generator->send_target) {
41-
if (Z_REFCOUNTED_P(generator->send_target)) Z_DELREF_P(generator->send_target);
39+
Z_TRY_DELREF_P(generator->send_target);
4240
generator->send_target = NULL;
4341
}
4442

45-
{
43+
if (execute_data->opline != execute_data->func->op_array.opcodes) {
44+
/* -1 required because we want the last run opcode, not the next to-be-run one. */
45+
uint32_t op_num = execute_data->opline - execute_data->func->op_array.opcodes - 1;
46+
4647
/* There may be calls to zend_vm_stack_free_call_frame(), which modifies the VM stack
4748
* globals, so need to load/restore those. */
4849
zend_vm_stack original_stack = EG(vm_stack);
@@ -847,7 +848,7 @@ ZEND_METHOD(Generator, next)
847848
}
848849
/* }}} */
849850

850-
/* {{{ proto mixed Generator::send(mixed $value)
851+
/* {{{ proto mixed Generator::send(mixed value)
851852
* Sends a value to the generator */
852853
ZEND_METHOD(Generator, send)
853854
{
@@ -886,7 +887,7 @@ ZEND_METHOD(Generator, send)
886887
}
887888
/* }}} */
888889

889-
/* {{{ proto mixed Generator::throw(Exception $exception)
890+
/* {{{ proto mixed Generator::throw(Exception exception)
890891
* Throws an exception into the generator */
891892
ZEND_METHOD(Generator, throw)
892893
{

Zend/zend_portability.h

+12
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,18 @@ char *alloca();
246246
# define HAVE_ATTRIBUTE_WEAK
247247
#endif
248248

249+
#if ZEND_GCC_VERSION >= 3001 || __has_builtin(__builtin_constant_p)
250+
# define HAVE_BUILTIN_CONSTANT_P
251+
#endif
252+
253+
#ifdef HAVE_BUILTIN_CONSTANT_P
254+
# define ZEND_CONST_COND(_condition, _default) \
255+
(__builtin_constant_p(_condition) ? (_condition) : (_default))
256+
#else
257+
# define ZEND_CONST_COND(_condition, _default) \
258+
(_default)
259+
#endif
260+
249261
#if ZEND_DEBUG
250262
# define zend_always_inline inline
251263
# define zend_never_inline

ext/dom/attr.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const zend_function_entry php_dom_attr_class_functions[] = {
5252
PHP_FE_END
5353
};
5454

55-
/* {{{ proto void DOMAttr::__construct(string name, [string value]); */
55+
/* {{{ proto void DOMAttr::__construct(string name, [string value]) */
5656
PHP_METHOD(domattr, __construct)
5757
{
5858
zval *id = getThis();
@@ -220,7 +220,7 @@ int dom_attr_schema_type_info_read(dom_object *obj, zval *retval)
220220

221221
/* }}} */
222222

223-
/* {{{ proto boolean dom_attr_is_id();
223+
/* {{{ proto boolean dom_attr_is_id()
224224
URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#Attr-isId
225225
Since: DOM Level 3
226226
*/

0 commit comments

Comments
 (0)