From: Tomi Ollila Date: Sat, 27 Apr 2013 09:33:16 +0000 (+0300) Subject: Re: [PATCH] don't store temporary value returned from c_str() X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=54d34dc7f1bfd30ad5e10ce8d18f760091aa9845;p=notmuch-archives.git Re: [PATCH] don't store temporary value returned from c_str() --- diff --git a/70/0e9b183e9560abb35f879e3656fa1f65a2e304 b/70/0e9b183e9560abb35f879e3656fa1f65a2e304 new file mode 100644 index 000000000..289cb3f60 --- /dev/null +++ b/70/0e9b183e9560abb35f879e3656fa1f65a2e304 @@ -0,0 +1,104 @@ +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 D5233431FAF + for ; Sat, 27 Apr 2013 02:33:20 -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 zK9mbM7l3GWh for ; + Sat, 27 Apr 2013 02:33:20 -0700 (PDT) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id DD124431FAE + for ; Sat, 27 Apr 2013 02:33:19 -0700 (PDT) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id 2F4841001F0; + Sat, 27 Apr 2013 12:33:17 +0300 (EEST) +From: Tomi Ollila +To: Vladimir.Marek@oracle.com, notmuch@notmuchmail.org +Subject: Re: [PATCH] don't store temporary value returned from c_str() +In-Reply-To: <1366405933-17223-1-git-send-email-Vladimir.Marek@oracle.com> +References: <1366405933-17223-1-git-send-email-Vladimir.Marek@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: 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: Sat, 27 Apr 2013 09:33:21 -0000 + +On Sat, Apr 20 2013, Vladimir.Marek@oracle.com wrote: + +> From: Vladimir Marek +> +> This is causing problems when compiled by Oracle Studio. Memory pointed +> by (const char*)term was already changed once talloc_strdup was called. + +If that changes, I'd like to understand why (and stated in the commit +message). If that is clear to everyone else I will withdraw the question -- +I am not too familiar with these iterators magic... :D + +Tomi + +> +> Signed-off-by: Vladimir Marek +> --- +> lib/message.cc | 9 ++++----- +> 1 files changed, 4 insertions(+), 5 deletions(-) +> +> diff --git a/lib/message.cc b/lib/message.cc +> index 8720c1b..8d329d1 100644 +> --- a/lib/message.cc +> +++ b/lib/message.cc +> @@ -266,18 +266,17 @@ _notmuch_message_get_term (notmuch_message_t *message, +> const char *prefix) +> { +> int prefix_len = strlen (prefix); +> - const char *term = NULL; +> 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)) +> + if (strncmp ((*i).c_str(), prefix, prefix_len)) +> return NULL; +> +> - value = talloc_strdup (message, term + prefix_len); +> + value = talloc_strdup (message, (*i).c_str() + prefix_len); +> +> #if DEBUG_DATABASE_SANITY +> i++; +> -- +> 1.7.3.2 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch