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 A9E1A431FBC for ; Thu, 2 May 2013 13:36:41 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 QsySbbVg337W for ; Thu, 2 May 2013 13:36:37 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com [209.85.217.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 569D0431FAF for ; Thu, 2 May 2013 13:36:37 -0700 (PDT) Received: by mail-lb0-f174.google.com with SMTP id r10so948120lbi.19 for ; Thu, 02 May 2013 13:36:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:in-reply-to:references:user-agent :date:message-id:mime-version:content-type:x-gm-message-state; bh=XIVfDqkvQiwl6hpYlGTTItHZTCMS3k9GJKBfU1HDSL8=; b=c6Fln6JSh4cnTj0aAaqyFsf1DDIIrnsOV+29RnM/OY8JimRqZXMfka16ORdateZrBo hzzwGBhcJFR+p5TJp55Ufa4M9DJQU2ZTG8J2kjkFTSMbypbSLAuM2hEuE6MOciryca0z aPUnQklk/LDXx+ElaQ/kKXpaYuWyOBzYuP+OaE39pMIGpexrfSJ+Lv3/yoSu5MdC9klz Yrg/MsomPy5I2Px3x4/qU8Ckex3gZ+tODLGjlD/tmxrJgjnj4r9E7xmuZgHrXruwgsYZ BZm+6O0hzVh/YMHBAJtl6T/NhMJstBmqY2owMD5vKL8ZznFkftS08HHXf8bqOp3UeWeH ozVg== X-Received: by 10.152.3.201 with SMTP id e9mr3140404lae.12.1367526995757; Thu, 02 May 2013 13:36:35 -0700 (PDT) Received: from localhost (dsl-hkibrasgw2-58c376-211.dhcp.inet.fi. [88.195.118.211]) by mx.google.com with ESMTPSA id x9sm3231397lbi.15.2013.05.02.13.36.33 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 02 May 2013 13:36:34 -0700 (PDT) From: Jani Nikula To: Tomi Ollila , Vladimir Marek Subject: Re: [PATCH 01/24] lib/message.cc: stale pointer bug In-Reply-To: References: <1367444021-2757-1-git-send-email-Vladimir.Marek@oracle.com> <20130502134530.GB23259@pub.cz.oracle.com> User-Agent: Notmuch/0.15.2+70~g2eeb96a (http://notmuchmail.org) Emacs/24.2.1 (x86_64-pc-linux-gnu) Date: Thu, 02 May 2013 23:36:30 +0300 Message-ID: <87mwsd3yr5.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain X-Gm-Message-State: ALoCoQnq5i7/18+ftMJtrhyvPF0upCKVUz9xL12dnavccf2T09o+AQsTVRMYW13wzt+hvclalzXe 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 20:36:42 -0000 On Thu, 02 May 2013, Tomi Ollila wrote: > 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 >;) I already dropped needs-review from the latest version [1]. I'm curious about patches 2-24, let's not stall here. ;) Jani. [1] id:1367505102-12860-1-git-send-email-Vladimir.Marek@oracle.com