return FAILURE;
}
if (EXPECTED(Z_TYPE(retval) == IS_STRING)) {
- if (readobj == writeobj) {
- zval_ptr_dtor(readobj);
- }
ZVAL_COPY_VALUE(writeobj, &retval);
return SUCCESS;
} else {
zval_ptr_dtor(&retval);
- if (readobj == writeobj) {
- zval_ptr_dtor(readobj);
- }
ZVAL_EMPTY_STRING(writeobj);
zend_error(E_RECOVERABLE_ERROR, "Method %s::__toString() must return a string value", ZSTR_VAL(ce->name));
return SUCCESS;
}
return FAILURE;
case _IS_BOOL:
- ZVAL_BOOL(writeobj, 1);
+ ZVAL_TRUE(writeobj);
return SUCCESS;
case IS_LONG:
ce = Z_OBJCE_P(readobj);
zend_error(E_NOTICE, "Object of class %s could not be converted to int", ZSTR_VAL(ce->name));
- if (readobj == writeobj) {
- zval_dtor(readobj);
- }
ZVAL_LONG(writeobj, 1);
return SUCCESS;
case IS_DOUBLE:
ce = Z_OBJCE_P(readobj);
zend_error(E_NOTICE, "Object of class %s could not be converted to float", ZSTR_VAL(ce->name));
- if (readobj == writeobj) {
- zval_dtor(readobj);
- }
ZVAL_DOUBLE(writeobj, 1);
return SUCCESS;
default:
typedef int (*zend_object_compare_t)(zval *object1, zval *object2);
typedef int (*zend_object_compare_zvals_t)(zval *resul, zval *op1, zval *op2);
-/* Cast an object to some other type
+/* Cast an object to some other type.
+ * readobj and retval must point to distinct zvals.
*/
typedef int (*zend_object_cast_t)(zval *readobj, zval *retval, int type);
}
}
- if (readobj == writeobj) {
- zval_ptr_dtor(readobj);
- }
-
rv = cast_object(writeobj, type, (char *)contents);
if (contents) {
switch (intern->type) {
case SPL_FS_INFO:
case SPL_FS_FILE:
- if (readobj == writeobj) {
- zval retval;
- zval *retval_ptr = &retval;
-
- ZVAL_STRINGL(retval_ptr, intern->file_name, intern->file_name_len);
- zval_ptr_dtor(readobj);
- ZVAL_NEW_STR(writeobj, Z_STR_P(retval_ptr));
- } else {
- ZVAL_STRINGL(writeobj, intern->file_name, intern->file_name_len);
- }
+ ZVAL_STRINGL(writeobj, intern->file_name, intern->file_name_len);
return SUCCESS;
case SPL_FS_DIR:
- if (readobj == writeobj) {
- zval retval;
- zval *retval_ptr = &retval;
-
- ZVAL_STRING(retval_ptr, intern->u.dir.entry.d_name);
- zval_ptr_dtor(readobj);
- ZVAL_NEW_STR(writeobj, Z_STR_P(retval_ptr));
- } else {
- ZVAL_STRING(writeobj, intern->u.dir.entry.d_name);
- }
+ ZVAL_STRING(writeobj, intern->u.dir.entry.d_name);
return SUCCESS;
}
} else if (type == _IS_BOOL) {
ZVAL_TRUE(writeobj);
return SUCCESS;
}
- if (readobj == writeobj) {
- zval_ptr_dtor(readobj);
- }
ZVAL_NULL(writeobj);
return FAILURE;
}