mirror of
https://git.notmuchmail.org/git/notmuch
synced 2025-01-03 15:21:41 +01:00
lib/message.cc: stale pointer bug (v3)
Xapian::TermIterator::operator* returns std::string which is destroyed as soon as (*i).c_str() finishes. The remembered pointer 'term' then references invalid memory. Signed-off-by: Vladimir Marek <vlmarek@volny.cz>
This commit is contained in:
parent
8bee3c417c
commit
51b073c6f2
1 changed files with 6 additions and 6 deletions
|
@ -266,18 +266,18 @@ _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 (!term || strncmp (term, prefix, prefix_len))
|
||||
if (i == end)
|
||||
return NULL;
|
||||
|
||||
value = talloc_strdup (message, term + prefix_len);
|
||||
std::string term = *i;
|
||||
if (strncmp (term.c_str(), prefix, prefix_len))
|
||||
return NULL;
|
||||
|
||||
value = talloc_strdup (message, term.c_str() + prefix_len);
|
||||
|
||||
#if DEBUG_DATABASE_SANITY
|
||||
i++;
|
||||
|
|
Loading…
Reference in a new issue