summaryrefslogtreecommitdiff
path: root/Zend/zend_object_handlers.c
diff options
context:
space:
mode:
authorJohannes Schlüter <johannes@php.net>2007-12-21 20:56:33 +0000
committerJohannes Schlüter <johannes@php.net>2007-12-21 20:56:33 +0000
commit1b6100f4c1b5e16bd1bc24843aa98b2b0d401218 (patch)
tree4daaad1eb2235919f852758cce5cedddb19f411b /Zend/zend_object_handlers.c
parentd27e5cd1528db907712bd814116cdbf1e8138ed1 (diff)
downloadphp-git-1b6100f4c1b5e16bd1bc24843aa98b2b0d401218.tar.gz
- MFH: Fix #43450 (Memory leak on some functions with implicit object
__toString() call) (Davic C.)
Diffstat (limited to 'Zend/zend_object_handlers.c')
-rw-r--r--Zend/zend_object_handlers.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 56ff4ab1b2..f68598107e 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -1191,6 +1191,9 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty
}
if (Z_TYPE_P(retval) == IS_STRING) {
INIT_PZVAL(writeobj);
+ if (readobj == writeobj) {
+ zval_dtor(readobj);
+ }
ZVAL_ZVAL(writeobj, retval, 1, 1);
if (Z_TYPE_P(writeobj) != type) {
convert_to_explicit_type(writeobj, type);
@@ -1199,6 +1202,9 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty
} else {
zval_ptr_dtor(&retval);
INIT_PZVAL(writeobj);
+ if (readobj == writeobj) {
+ zval_dtor(readobj);
+ }
ZVAL_EMPTY_STRING(writeobj);
zend_error(E_RECOVERABLE_ERROR, "Method %s::__toString() must return a string value", ce->name);
return SUCCESS;
@@ -1213,15 +1219,23 @@ ZEND_API int zend_std_cast_object_tostring(zval *readobj, zval *writeobj, int ty
ce = Z_OBJCE_P(readobj);
zend_error(E_NOTICE, "Object of class %s could not be converted to int", ce->name);
INIT_PZVAL(writeobj);
+ 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 double", ce->name);
INIT_PZVAL(writeobj);
+ if (readobj == writeobj) {
+ zval_dtor(readobj);
+ }
ZVAL_DOUBLE(writeobj, 1);
return SUCCESS;
default:
+ INIT_PZVAL(writeobj);
+ Z_TYPE_P(writeobj) = IS_NULL;
break;
}
return FAILURE;