]> granicus.if.org Git - php/commitdiff
Better fix for the memleaks (bug 19943) by Moriyoshi
authorfoobar <sniper@php.net>
Fri, 7 Mar 2003 00:28:25 +0000 (00:28 +0000)
committerfoobar <sniper@php.net>
Fri, 7 Mar 2003 00:28:25 +0000 (00:28 +0000)
Zend/zend_execute.c

index 0472d193fcdb192db6fe90f854c43499b3479ecd..ffa61307d57ab793c8baeaeb7ccb6d6a852c1268 100644 (file)
@@ -466,10 +466,20 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2
                                                }
 
                                                T->EA.data.str_offset.str->value.str.val[T->EA.data.str_offset.offset] = final_value->value.str.val[0];
-                                               if (op2
-                                                       && op2->op_type != IS_VAR
-                                                       && final_value == &T(op2->u.var).tmp_var) {
-                                                       STR_FREE(final_value->value.str.val);       
+                                               
+                                               if (op2) {
+                                                       if (op2->op_type == IS_VAR) {
+                                                               if (value == &T(op2->u.var).tmp_var) {
+                                                                       STR_FREE(value->value.str.val);
+                                                               }
+                                                       } else {
+                                                               if (final_value == &T(op2->u.var).tmp_var) {
+                                                                       /* we can safely free final_value here
+                                                                        * because separation is done only
+                                                                        * in case op2->op_type == IS_VAR */
+                                                                       STR_FREE(final_value->value.str.val);
+                                                               }
+                                                       }
                                                }
                                                if (final_value == &tmp) {
                                                        zval_dtor(final_value);