Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:26401 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60547 invoked by uid 1010); 7 Nov 2006 11:01:15 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 60532 invoked from network); 7 Nov 2006 11:01:15 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Nov 2006 11:01:15 -0000 Authentication-Results: pb1.pair.com smtp.mail=php_lists@realplain.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=php_lists@realplain.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain realplain.com from 209.142.136.51 cause and error) X-PHP-List-Original-Sender: php_lists@realplain.com X-Host-Fingerprint: 209.142.136.51 neville-out.centurytel.net Linux 2.5 (sometimes 2.4) (4) Received: from [209.142.136.51] ([209.142.136.51:39387] helo=neville-out.centurytel.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4A/20-58090-A7760554 for ; Tue, 07 Nov 2006 06:01:15 -0500 Received: from msa2-mx.centurytel.net (msa2-mx.centurytel.net [209.142.136.132]) by neville-out.centurytel.net (Postfix) with ESMTP id CB31215F6DD for ; Tue, 7 Nov 2006 04:52:57 -0600 (CST) Received: from pc1 (d31-240.rt-bras.wnvl.centurytel.net [69.179.158.240]) by msa2-mx.centurytel.net (8.13.6/8.13.6) with SMTP id kA7Aqce8027076 for ; Tue, 7 Nov 2006 04:52:38 -0600 Message-ID: <018201c7025a$d8042150$0201a8c0@pc1> To: Date: Tue, 7 Nov 2006 04:52:39 -0600 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_017F_01C70228.8D249200" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Subject: [PATCH] =& doesn't remove "old" references like unset() From: php_lists@realplain.com ("Matt Wilmas") ------=_NextPart_000_017F_01C70228.8D249200 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi (Dmitry?), See Bug #33282 -- I saw it in the Bug Summary; don't know if there are other related ones... Same applies to foreach ($arr ... &$v) which is where I noticed it last week with var_dump($arr). All elements that WERE referenced but aren't anymore still have is_ref=1 (when refcount=1). Only the last referenced element should be a reference (unless the others were to begin with). unset()'ing the reference variable removes the reference from the last element. Example: $a = array(1, 2, 3); $r = &$a[0]; $r = &$a[1]; $r = &$a[2]; var_dump($a); array(3) { [0]=> &int(1) [1]=> &int(2) [2]=> &int(3) // unset($r) will take care of this one } The reference (&) should no longer be on the first 2 elements, right? Setting is_ref=0 when refcount=1 in zend_assign_to_variable_reference() fixes it. I assume it won't cause other problems since the same thing is done in zval_ptr_dtor(). :-) Thanks, Matt ------=_NextPart_000_017F_01C70228.8D249200 Content-Type: text/plain; name="ref_patch.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ref_patch.txt" Index: zend_execute.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /repository/ZendEngine2/zend_execute.c,v=0A= retrieving revision 1.752=0A= diff -u -r1.752 zend_execute.c=0A= --- zend_execute.c 2 Oct 2006 11:05:02 -0000 1.752=0A= +++ zend_execute.c 7 Nov 2006 05:24:38 -0000=0A= @@ -438,6 +438,8 @@=0A= if (variable_ptr->refcount=3D=3D0) {=0A= zendi_zval_dtor(*variable_ptr);=0A= FREE_ZVAL(variable_ptr);=0A= + } else if (variable_ptr->refcount =3D=3D 1) {=0A= + variable_ptr->is_ref =3D 0;=0A= }=0A= } else if (!variable_ptr->is_ref) {=0A= if (variable_ptr_ptr =3D=3D value_ptr_ptr) {=0A= ------=_NextPart_000_017F_01C70228.8D249200 Content-Type: text/plain; name="ref_patch_5_2.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ref_patch_5_2.txt" Index: zend_execute.c=0A= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= RCS file: /repository/ZendEngine2/zend_execute.c,v=0A= retrieving revision 1.716.2.12.2.12=0A= diff -u -r1.716.2.12.2.12 zend_execute.c=0A= --- zend_execute.c 2 Oct 2006 11:09:52 -0000 1.716.2.12.2.12=0A= +++ zend_execute.c 7 Nov 2006 05:24:40 -0000=0A= @@ -415,6 +415,8 @@=0A= if (variable_ptr->refcount=3D=3D0) {=0A= zendi_zval_dtor(*variable_ptr);=0A= FREE_ZVAL(variable_ptr);=0A= + } else if (variable_ptr->refcount =3D=3D 1) {=0A= + variable_ptr->is_ref =3D 0;=0A= }=0A= } else if (!variable_ptr->is_ref) {=0A= if (variable_ptr_ptr =3D=3D value_ptr_ptr) {=0A= ------=_NextPart_000_017F_01C70228.8D249200--