From: Vladimir.Marek Date: Fri, 19 Apr 2013 21:12:13 +0000 (+0200) Subject: [PATCH] don't store temporary value returned from c_str() X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4d9f7052a5380a0ab1d9f2d0bf7330936f751c65;p=notmuch-archives.git [PATCH] don't store temporary value returned from c_str() --- diff --git a/57/53cc8c2da87284806005fd66da28f7f8c2d0c8 b/57/53cc8c2da87284806005fd66da28f7f8c2d0c8 new file mode 100644 index 000000000..c3e04bf41 --- /dev/null +++ b/57/53cc8c2da87284806005fd66da28f7f8c2d0c8 @@ -0,0 +1,100 @@ +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 91465431FB6 + for ; Fri, 19 Apr 2013 14:14:40 -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 c0exDw3deh-l for ; + Fri, 19 Apr 2013 14:14:40 -0700 (PDT) +Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id E3E13431FAE + for ; Fri, 19 Apr 2013 14:14:39 -0700 (PDT) +Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) + by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with + ESMTP id r3JLEbwO021731 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); + Fri, 19 Apr 2013 21:14:38 GMT +Received: from aserz7021.oracle.com (aserz7021.oracle.com [141.146.126.230]) + by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id + r3JLEaUC027226 + (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); + Fri, 19 Apr 2013 21:14:37 GMT +Received: from abhmt118.oracle.com (abhmt118.oracle.com [141.146.116.70]) + by aserz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id + r3JLEa8J014693; Fri, 19 Apr 2013 21:14:36 GMT +Received: from pub.cz.oracle.com (/10.163.101.122) + by default (Oracle Beehive Gateway v4.0) + with ESMTP ; Fri, 19 Apr 2013 14:14:36 -0700 +From: Vladimir.Marek@oracle.com +To: notmuch@notmuchmail.org +Subject: [PATCH] don't store temporary value returned from c_str() +Date: Fri, 19 Apr 2013 23:12:13 +0200 +Message-Id: <1366405933-17223-1-git-send-email-Vladimir.Marek@oracle.com> +X-Mailer: git-send-email 1.7.3.2 +X-Source-IP: ucsinet21.oracle.com [156.151.31.93] +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: Fri, 19 Apr 2013 21:14:40 -0000 + +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. + +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 +