From cde694c5e185ef1af5a5f5be94c6663be6ad1c6e Mon Sep 17 00:00:00 2001 From: Alon Albert Date: Tue, 12 Nov 2013 15:33:45 -0800 Subject: [PATCH] Check for ArrayIndexOutOfBoundsException Quoted text pos may be out of bounds of message body. This may be caused by the pos being calculated in html while the message is being sent as plain text. A seperate CL will attempt to address the root cause. This is a last resort so we don't crash. Bug: 11538910 Change-Id: I326ebe56ee15368983caa2fa76605e7658dab014 --- .../android/emailcommon/internet/Rfc822Output.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java b/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java index 17dff5cbd..ce02d105b 100644 --- a/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java +++ b/emailcommon/src/com/android/emailcommon/internet/Rfc822Output.java @@ -94,11 +94,16 @@ public class Rfc822Output { return new String[2]; } String[] messageBody = new String[] { body.mTextContent, body.mHtmlContent }; - if (useSmartReply && body.mQuotedTextStartPos > 0) { + final int pos = body.mQuotedTextStartPos; + if (useSmartReply && pos > 0) { if (messageBody[0] != null) { - messageBody[0] = messageBody[0].substring(0, body.mQuotedTextStartPos); + if (pos < messageBody[0].length()) { + messageBody[0] = messageBody[0].substring(0, pos); + } } else if (messageBody[1] != null) { - messageBody[1] = messageBody[1].substring(0, body.mQuotedTextStartPos); + if (pos < messageBody[1].length()) { + messageBody[1] = messageBody[1].substring(0, pos); + } } } return messageBody;