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 A5D12431FAF for ; Thu, 2 May 2013 11:03:26 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] 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 hUl6GlmkfTh2 for ; Thu, 2 May 2013 11:03:23 -0700 (PDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id D753D431FB6 for ; Thu, 2 May 2013 11:03:22 -0700 (PDT) Received: from guru.guru-group.fi (localhost [IPv6:::1]) by guru.guru-group.fi (Postfix) with ESMTP id 8AFA4100044; Thu, 2 May 2013 21:03:20 +0300 (EEST) From: Tomi Ollila To: Vladimir Marek Subject: Re: [PATCH 01/24] lib/message.cc: stale pointer bug In-Reply-To: <20130502134530.GB23259@pub.cz.oracle.com> References: <1367444021-2757-1-git-send-email-Vladimir.Marek@oracle.com> <20130502134530.GB23259@pub.cz.oracle.com> User-Agent: Notmuch/0.15.2+75~gd7fa7c4 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain 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 18:03:26 -0000 On Thu, May 02 2013, Vladimir Marek wrote: >> > 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! I am not that smart (i.e. avoid copy constructor it might be, I don't know...) I am lousy in c++. I attempter to mean http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization in a sense that when variable is introduced it is also initialized to useful value (so that no-one accidentally add code between introduction and initialization). Anyway, if you rework the patch then we can vote which version to apply (yeah, sure >;) > -- > Vlad Tomi