summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-10-13 13:52:31 +0200
committerAnatol Belski <ab@php.net>2014-10-13 13:52:31 +0200
commit19c41e1f538e854fa8450715791c44f55e909588 (patch)
treeff89ca91ab2e7d0add6d6e8d056536547c281498 /ext
parente1cd0e0a38deb91d24ded68df010b7f6c03d2cb6 (diff)
parent702a2dfb3ef3c603d89bf7e4e9a63b6f8ff8968d (diff)
downloadphp-git-19c41e1f538e854fa8450715791c44f55e909588.tar.gz
Merge remote-tracking branch 'origin/master' into native-tls
* origin/master: We can't eliminate FETCH_CONSTANT opcodes for constants represented by AST. Ensure __LINE__ is always accurate Fix incdec of referenced properties Fix ::jsonSerialize() failure message Fix invalid zend_string_frees in reflection Remove retval member in spl_dllist DLL export several APIs needed for phpdbg More fixes for nodelist array access - testing for null property read - no zval copying if the type is already long - memory fix for master
Diffstat (limited to 'ext')
-rw-r--r--ext/dom/php_dom.c21
-rw-r--r--ext/dom/tests/bug67949.phpt32
-rw-r--r--ext/json/json.c2
-rw-r--r--ext/opcache/Optimizer/pass1_5.c6
-rw-r--r--ext/reflection/php_reflection.c6
-rw-r--r--ext/spl/spl_dllist.c8
6 files changed, 48 insertions, 27 deletions
diff --git a/ext/dom/php_dom.c b/ext/dom/php_dom.c
index 71c06612db..c25cbaba58 100644
--- a/ext/dom/php_dom.c
+++ b/ext/dom/php_dom.c
@@ -1552,8 +1552,7 @@ zval *dom_nodelist_read_dimension(zval *object, zval *offset, int type, zval *rv
return NULL;
}
- ZVAL_COPY(&offset_copy, offset);
- convert_to_long(&offset_copy);
+ ZVAL_LONG(&offset_copy, zval_get_long(offset));
zend_call_method_with_1_params(object, Z_OBJCE_P(object), NULL, "item", rv, &offset_copy);
@@ -1562,21 +1561,15 @@ zval *dom_nodelist_read_dimension(zval *object, zval *offset, int type, zval *rv
int dom_nodelist_has_dimension(zval *object, zval *member, int check_empty TSRMLS_DC)
{
- zval *length, offset_copy;
- int ret;
-
- ZVAL_COPY(&offset_copy, member);
- convert_to_long(&offset_copy);
+ zend_long offset = zval_get_long(member);
- if (Z_LVAL(offset_copy) < 0) {
+ if (offset < 0) {
return 0;
- }
-
- length = zend_read_property(Z_OBJCE_P(object), object, "length", sizeof("length") - 1, 0 TSRMLS_CC);
-
- ret = Z_LVAL(offset_copy) < Z_LVAL_P(length);
+ } else {
+ zval *length = zend_read_property(Z_OBJCE_P(object), object, "length", sizeof("length") - 1, 0 TSRMLS_CC);
- return ret;
+ return length && offset < Z_LVAL_P(length);
+ }
} /* }}} end dom_nodelist_has_dimension */
#endif /* HAVE_DOM */
diff --git a/ext/dom/tests/bug67949.phpt b/ext/dom/tests/bug67949.phpt
index fc29881ca7..e4eb6f724f 100644
--- a/ext/dom/tests/bug67949.phpt
+++ b/ext/dom/tests/bug67949.phpt
@@ -22,11 +22,21 @@ var_dump($nodes[0]->textContent);
var_dump($nodes[1]->textContent);
echo "testing offset not a long\n";
-$offset = 'test';
+$offset = ['test'];
+var_dump($offset);
+var_dump(isset($nodes[$offset]), $nodes[$offset]->textContent);
+var_dump($offset);
+
+$something = 'test';
+$offset = &$something;
+
+var_dump($offset);
+var_dump(isset($nodes[$offset]), $nodes[$offset]->textContent);
var_dump($offset);
-var_dump($nodes[$offset]->textContent);
+
+$offset = 'test';
var_dump($offset);
-var_dump(isset($nodes[$offset]));
+var_dump(isset($nodes[$offset]), $nodes[$offset]->textContent);
var_dump($offset);
echo "testing read_dimension with null offset\n";
@@ -49,13 +59,29 @@ string(4) "data"
Notice: Trying to get property of non-object in %s on line %d
NULL
testing offset not a long
+array(1) {
+ [0]=>
+ string(4) "test"
+}
+
+Notice: Trying to get property of non-object in %s on line %d
+bool(false)
+NULL
+array(1) {
+ [0]=>
+ string(4) "test"
+}
string(4) "test"
+bool(true)
string(4) "data"
string(4) "test"
+string(4) "test"
bool(true)
+string(4) "data"
string(4) "test"
testing read_dimension with null offset
NULL
testing attribute access
string(4) "href"
==DONE==
+
diff --git a/ext/json/json.c b/ext/json/json.c
index 16e452a004..8f4f281ef1 100644
--- a/ext/json/json.c
+++ b/ext/json/json.c
@@ -571,7 +571,7 @@ static void json_encode_serializable_object(smart_str *buf, zval *val, int optio
ZVAL_STRING(&fname, "jsonSerialize");
if (FAILURE == call_user_function_ex(EG(function_table), val, &fname, &retval, 0, NULL, 1, NULL TSRMLS_CC) || Z_TYPE(retval) == IS_UNDEF) {
- zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Failed calling %s::jsonSerialize()", ce->name);
+ zend_throw_exception_ex(NULL, 0 TSRMLS_CC, "Failed calling %s::jsonSerialize()", ce->name->val);
smart_str_appendl(buf, "null", sizeof("null") - 1);
zval_ptr_dtor(&fname);
return;
diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c
index f06f5cc559..b91ac5b50f 100644
--- a/ext/opcache/Optimizer/pass1_5.c
+++ b/ext/opcache/Optimizer/pass1_5.c
@@ -266,6 +266,9 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx TSRML
break;
}
}
+ if (Z_TYPE(c) == IS_CONSTANT_AST) {
+ break;
+ }
literal_dtor(&ZEND_OP2_LITERAL(opline));
MAKE_NOP(opline);
zend_optimizer_replace_by_const(op_array, opline, IS_TMP_VAR, tv, &c TSRMLS_CC);
@@ -312,6 +315,9 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx TSRML
if ((c = zend_hash_find(&ce->constants_table,
Z_STR(ZEND_OP2_LITERAL(opline)))) != NULL) {
ZVAL_DEREF(c);
+ if (Z_TYPE_P(c) == IS_CONSTANT_AST) {
+ break;
+ }
if (ZEND_IS_CONSTANT_TYPE(Z_TYPE_P(c))) {
if (!zend_optimizer_get_persistent_constant(Z_STR_P(c), &t, 1 TSRMLS_CC) ||
ZEND_IS_CONSTANT_TYPE(Z_TYPE(t))) {
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index 7291d64213..57e11945c1 100644
--- a/ext/reflection/php_reflection.c
+++ b/ext/reflection/php_reflection.c
@@ -2402,7 +2402,7 @@ ZEND_METHOD(reflection_parameter, getClass)
} else {
zend_string *name = zend_string_init(param->arg_info->class_name, param->arg_info->class_name_len, 0);
ce = zend_lookup_class(name TSRMLS_CC);
- zend_string_free(name);
+ zend_string_release(name);
if (!ce) {
zend_throw_exception_ex(reflection_exception_ptr, 0 TSRMLS_CC,
"Class %s does not exist", param->arg_info->class_name);
@@ -3862,10 +3862,10 @@ ZEND_METHOD(reflection_class, getProperty)
if (!EG(exception)) {
zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Class %s does not exist", classname->val);
}
- zend_string_free(classname);
+ zend_string_release(classname);
return;
}
- zend_string_free(classname);
+ zend_string_release(classname);
if (!instanceof_function(ce, ce2 TSRMLS_CC)) {
zend_throw_exception_ex(reflection_exception_ptr, -1 TSRMLS_CC, "Fully qualified property name %s::%s does not specify a base class of %s", ce2->name->val, str_name, ce->name->val);
diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c
index 0a6f97c563..945f7c7ab4 100644
--- a/ext/spl/spl_dllist.c
+++ b/ext/spl/spl_dllist.c
@@ -86,7 +86,6 @@ struct _spl_dllist_object {
spl_ptr_llist *llist;
int traverse_position;
spl_ptr_llist_element *traverse_pointer;
- zval retval;
int flags;
zend_function *fptr_offset_get;
zend_function *fptr_offset_set;
@@ -358,7 +357,6 @@ static void spl_dllist_object_free_storage(zend_object *object TSRMLS_DC) /* {{{
spl_ptr_llist_destroy(intern->llist TSRMLS_CC);
SPL_LLIST_CHECK_DELREF(intern->traverse_pointer);
- zval_ptr_dtor(&intern->retval);
if (intern->debug_info != NULL) {
zend_hash_destroy(intern->debug_info);
@@ -482,10 +480,8 @@ static int spl_dllist_object_count_elements(zval *object, zend_long *count TSRML
zval rv;
zend_call_method_with_0_params(object, intern->std.ce, &intern->fptr_count, "count", &rv);
if (!Z_ISUNDEF(rv)) {
- zval_ptr_dtor(&intern->retval);
- ZVAL_ZVAL(&intern->retval, &rv, 0, 0);
- convert_to_long(&intern->retval);
- *count = (zend_long) Z_LVAL(intern->retval);
+ *count = zval_get_long(&rv);
+ zval_ptr_dtor(&rv);
return SUCCESS;
}
*count = 0;