Bug 770262 - crash in mozalloc_abort ... nsMsgSearchTerm::MatchBody, r=neil,a=Standard8
authorKent James <kent@caspia.com>
Sat, 01 Sep 2012 10:40:26 -0700
changeset 30855 b4366b1e750cff87b687c87bb043abe5264b085f
parent 30854 7621b825fdaa703bace0bc3c1da4e5c1ee079028
child 30856 4c39c77cfe368a31e39ac1e433c0feeb958a2a43
push id1
push userclokep@gmail.com
push dateMon, 07 May 2018 22:45:56 +0000
treeherdercomm-esr60@57eacde5ef40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersneil, Standard8
bugs770262
Bug 770262 - crash in mozalloc_abort ... nsMsgSearchTerm::MatchBody, r=neil,a=Standard8
mailnews/base/search/src/nsMsgSearchTerm.cpp
--- a/mailnews/base/search/src/nsMsgSearchTerm.cpp
+++ b/mailnews/base/search/src/nsMsgSearchTerm.cpp
@@ -949,17 +949,20 @@ nsresult nsMsgSearchTerm::MatchBody (nsI
       bool softLineBreak = false;
       // Do in-place decoding of quoted printable
       if (isQuotedPrintable)
       {
         softLineBreak = StringEndsWith(buf, NS_LITERAL_CSTRING("="));
         MsgStripQuotedPrintable ((unsigned char*)buf.get());
         // in case the string shrunk, reset the length. If soft line break,
         // chop off the last char as well.
-        buf.SetLength(strlen(buf.get()) - (softLineBreak ? 1 : 0));
+        size_t bufLength = strlen(buf.get());
+        if ((bufLength > 0) && softLineBreak)
+          --bufLength;
+        buf.SetLength(bufLength);
       }
       compare.Append(buf);
       // If this line ends with a soft line break, loop around
       // and get the next line before looking for the search string.
       // This assumes the message can't end on a QP soft-line break.
       // That seems like a pretty safe assumption.
       if (softLineBreak)
         continue;