Avoid out of bound exception getting attachment by index

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@107 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2007-11-16 16:18:36 +00:00
parent 67e4c1b3b8
commit e133b81599
1 changed files with 3 additions and 1 deletions

View File

@ -1388,7 +1388,9 @@ public class ExchangeSession {
// try to get attachment by index, only if no name found
// or attachment renamed to winmail.dat by Exchange
if (attachment == null && (partHeader.name == null || "winmail.dat".equals(partHeader.name))) {
if (attachment == null && (partHeader.name == null || "winmail.dat".equals(partHeader.name))
// avoid out of bounds exception
&& attachmentIndex >= 0 && attachmentIndex < attachments.size()) {
attachment = attachments.get(attachmentIndex);
}