]> git.notmuchmail.org Git - notmuch/commitdiff
Avoid reading a byte just before our allocated buffer.
authorCarl Worth <cworth@cworth.org>
Fri, 16 Oct 2009 20:38:43 +0000 (13:38 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 16 Oct 2009 20:38:43 +0000 (13:38 -0700)
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.

notmuch-index-message.cc

index 3175d2d829b26b9c8db72d9d962bdf141cdb9851..dd3fbb44687ba1859be696bf86ae9ee12a86b8dd 100644 (file)
@@ -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;