Return-Path: Delivered-To: apmail-perl-dev-archive@www.apache.org Received: (qmail 57562 invoked from network); 11 Oct 2007 13:51:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 11 Oct 2007 13:51:37 -0000 Received: (qmail 94937 invoked by uid 500); 11 Oct 2007 13:51:25 -0000 Delivered-To: apmail-perl-dev-archive@perl.apache.org Received: (qmail 94926 invoked by uid 500); 11 Oct 2007 13:51:25 -0000 Mailing-List: contact dev-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list dev@perl.apache.org Received: (qmail 94913 invoked by uid 99); 11 Oct 2007 13:51:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 11 Oct 2007 06:51:24 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of torsten.foertsch@gmx.net designates 213.165.64.20 as permitted sender) Received: from [213.165.64.20] (HELO mail.gmx.net) (213.165.64.20) by apache.org (qpsmtpd/0.29) with SMTP; Thu, 11 Oct 2007 13:51:27 +0000 Received: (qmail invoked by alias); 11 Oct 2007 13:51:05 -0000 Received: from dialin096079.justdsl.de (EHLO opi.home) [85.25.96.79] by mail.gmx.net (mp058) with SMTP; 11 Oct 2007 15:51:05 +0200 X-Authenticated: #1700068 X-Provags-ID: V01U2FsdGVkX1+6NAl2fKm6cEbAS6vwS4U/mgoKaSBZQ6lQa6uPNW Q9TnBOdIzTmaPz Received: by opi.home (Postfix, from userid 1000) id 6E2AFC2EC0; Thu, 11 Oct 2007 15:51:04 +0200 (CEST) From: Torsten Foertsch To: dev@perl.apache.org Subject: Re: possible pnotes refcounting bug ? Date: Thu, 11 Oct 2007 15:50:59 +0200 User-Agent: KMail/1.9.5 References: <200710111518.18560.torsten.foertsch@gmx.net> In-Reply-To: <200710111518.18560.torsten.foertsch@gmx.net> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart2587405.MqSH3xWCms"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200710111551.03735.torsten.foertsch@gmx.net> X-Y-GMX-Trusted: 0 X-Virus-Checked: Checked by ClamAV on apache.org --nextPart2587405.MqSH3xWCms Content-Type: text/plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Content-Disposition: inline On Thursday 11 October 2007 15:18, Torsten Foertsch wrote: > if (key) { > STRLEN len; > char *k = SvPV(key, len); > > if (val) { > retval = *hv_store(*pnotes, k, len, SvREFCNT_inc(val), 0); > } > else if (hv_exists(*pnotes, k, len)) { > retval = *hv_fetch(*pnotes, k, len, FALSE); > } > } > else { > retval = newRV_inc((SV *)*pnotes); > } > > return retval ? SvREFCNT_inc(retval) : &PL_sv_undef; > > I am wondering whether the REFCNT is always right. *pnotes is a HV. If the > function is called without a key argument the else branch newRV_inc > increments the REFCNT of the HV, right? Then the return statement in the > last line increments it again? Am I wrong? I think it should rather read: if (key) { STRLEN len; char *k = SvPV(key, len); if (val) { retval = *hv_store(*pnotes, k, len, SvREFCNT_inc(val), 0); } else if (hv_exists(*pnotes, k, len)) { retval = *hv_fetch(*pnotes, k, len, FALSE); } return retval ? SvREFCNT_inc(retval) : &PL_sv_undef; } else { return newRV_inc((SV *)*pnotes); } Torsten --nextPart2587405.MqSH3xWCms Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (GNU/Linux) iD8DBQBHDipHwicyCTir8T4RAgVSAKDHzibphnxA0MhKCqZKTSdKs/RmQQCffCHe u7J0UxfFJnWnVHTHYu5fclE= =kPou -----END PGP SIGNATURE----- --nextPart2587405.MqSH3xWCms--