[PATCH] emacs: Fix stack overflow in notmuch-wash-tidy-citations

Michal Sojka sojkam1 at fel.cvut.cz
Fri Jul 16 04:32:35 PDT 2010


The following message (146 kB) breaks the emacs interface:
http://rtime.felk.cvut.cz/~sojka/notmuch/notmuch-wash-tidy-citations-stack-overflow.txt

An attempt to view the message produced message
"notmuch-wash-tidy-citations: Stack overflow in regexp matcherq" and
it was not possible to work with the message.

I tracked the problem down to the regexp search, which probably
attempts to match a very big piece of text (several lines). I changed
the regexp to only match a single line. The result is probably slower,
but doesn't produce the error.
---
 emacs/notmuch-wash.el |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/emacs/notmuch-wash.el b/emacs/notmuch-wash.el
index 26a3f88..051dd17 100644
--- a/emacs/notmuch-wash.el
+++ b/emacs/notmuch-wash.el
@@ -218,7 +218,7 @@ Perform four transformations on the message body:
 
   ;; Insert a blank line before a citation if there isn't one.
   (goto-char (point-min))
-  (while (re-search-forward "\\(^[^>]+\\)\n>" nil t)
+  (while (re-search-forward "\\(^[^>][^\n]+\\)\n>" nil t)
     (replace-match "\\1\n\n>"))
 
   ;; Insert a blank line after a citation if there isn't one.
-- 
1.7.1.3.g75e44



More information about the notmuch mailing list