From: Vladimir Marek Date: Thu, 2 May 2013 13:45:30 +0000 (+0200) Subject: Re: [PATCH 01/24] lib/message.cc: stale pointer bug X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e0d7c9b5fcab519f8bf1bb6af79d7c4cbf99e0a7;p=notmuch-archives.git Re: [PATCH 01/24] lib/message.cc: stale pointer bug --- diff --git a/5b/ac852e635da6f1011682721d39191bac10611f b/5b/ac852e635da6f1011682721d39191bac10611f new file mode 100644 index 000000000..6b64f4d30 --- /dev/null +++ b/5b/ac852e635da6f1011682721d39191bac10611f @@ -0,0 +1,91 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id B76BD431FB6 + for ; Thu, 2 May 2013 06:47:46 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -2.299 +X-Spam-Level: +X-Spam-Status: No, score=-2.299 tagged_above=-999 required=5 + tests=[RCVD_IN_DNSWL_MED=-2.3, UNPARSEABLE_RELAY=0.001] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id GGxPf0EJVozU for ; + Thu, 2 May 2013 06:47:40 -0700 (PDT) +Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 8B7BF431FAF + for ; Thu, 2 May 2013 06:47:40 -0700 (PDT) +Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) + by aserp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with + ESMTP id r42DlS1g018481 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Thu, 2 May 2013 13:47:29 GMT +Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) + by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id + r42DlRh7028188 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); + Thu, 2 May 2013 13:47:28 GMT +Received: from abhmt114.oracle.com (abhmt114.oracle.com [141.146.116.66]) + by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id + r42DlRNj003864; Thu, 2 May 2013 13:47:27 GMT +Received: from pub.cz.oracle.com (/10.163.101.122) + by default (Oracle Beehive Gateway v4.0) + with ESMTP ; Thu, 02 May 2013 06:47:27 -0700 +Date: Thu, 2 May 2013 15:45:30 +0200 +From: Vladimir Marek +To: Tomi Ollila +Subject: Re: [PATCH 01/24] lib/message.cc: stale pointer bug +Message-ID: <20130502134530.GB23259@pub.cz.oracle.com> +Mail-Followup-To: Tomi Ollila , notmuch@notmuchmail.org, + Vladimir Marek +References: <1367444021-2757-1-git-send-email-Vladimir.Marek@oracle.com> + +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf-8 +Content-Disposition: inline +In-Reply-To: +User-Agent: Mutt/1.5.21 (2010-09-15) +X-Source-IP: acsinet21.oracle.com [141.146.126.237] +Cc: notmuch@notmuchmail.org, Vladimir Marek +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Thu, 02 May 2013 13:47:47 -0000 + +> > int prefix_len = strlen (prefix); +> > - const char *term = NULL; +> > + std::string term; +> > char *value; +> > +> > i.skip_to (prefix); +> > +> > - if (i != end) +> > - term = (*i).c_str (); +> > + if (i == end) +> > + return NULL; +> > +> > - if (!term || strncmp (term, prefix, prefix_len)) +> > + term = *i; +> +> ... hmm, a raii(?) solution above would be std::string term = *i; + +I'm not sure what's raii (I'm not very good at c++ ...), but I guess you +mean to use 'std::string term = *i;' to avoid copy constructor. That +surely is a good idea. Let me rework the patch! + +-- + Vlad