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