From: Carl Worth Date: Fri, 16 Oct 2009 20:38:43 +0000 (-0700) Subject: Avoid reading a byte just before our allocated buffer. X-Git-Tag: 0.1~848 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=dcebf35ec9d177720a120fd8601f966d169d2edf Avoid reading a byte just before our allocated buffer. When looking for a trailing ':' to introduce a quotation we peek at the last character before a newline. But for blank lines, that's not where we want to look. And when the first line in our buffer is a blank line, we're underrunning our buffer. The fix is easy---just bail early on blank lines since they have no terms anyway. Thanks to valgrind for pointing out this error. --- diff --git a/notmuch-index-message.cc b/notmuch-index-message.cc index 3175d2d8..dd3fbb44 100644 --- a/notmuch-index-message.cc +++ b/notmuch-index-message.cc @@ -486,6 +486,10 @@ gen_terms_body_str (Xapian::TermGenerator term_gen, while (*next_line == '\n') next_line++; + /* Skip blank lines. */ + if (line_end < line) + continue; + /* Skip lines that are quotes. */ if (*line == '>') continue;