unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] don't store temporary value returned from c_str()
@ 2013-04-19 21:12 Vladimir.Marek
  2013-04-27  9:33 ` Tomi Ollila
  2013-04-27 12:30 ` Jani Nikula
  0 siblings, 2 replies; 14+ messages in thread
From: Vladimir.Marek @ 2013-04-19 21:12 UTC (permalink / raw)
  To: notmuch; +Cc: Vladimir Marek

From: Vladimir Marek <vlmarek@volny.cz>

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 <vlmarek@volny.cz>
---
 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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-05-01 21:35 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-19 21:12 [PATCH] don't store temporary value returned from c_str() Vladimir.Marek
2013-04-27  9:33 ` Tomi Ollila
2013-04-27 10:11   ` Vladimir Marek
2013-04-27 11:53     ` David Bremner
2013-04-27 15:59       ` Vladimir Marek
2013-04-30  6:12     ` Kim Minh Kaplan
2013-04-30  8:48       ` Vladimir Marek
2013-04-30  9:44         ` Kim Minh Kaplan
2013-05-01 11:28           ` Vladimir Marek
2013-04-27 12:30 ` Jani Nikula
2013-04-27 13:22   ` Tomi Ollila
2013-04-27 16:05   ` Vladimir Marek
2013-04-29 21:23     ` David Bremner
2013-05-01 21:33       ` Vladimir Marek

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).