Skip to content

Commit

Permalink
fixed NPE when saving .msg attachments using right-click. #1986
Browse files Browse the repository at this point in the history
  • Loading branch information
j-dimension committed Sep 26, 2023
1 parent 2e603a9 commit fd1bdd8
Showing 1 changed file with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1782,8 +1782,10 @@ private void lstAttachmentsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FI
data = EmailUtils.getAttachmentBytes(this.lstAttachments.getSelectedValue().toString(), this.emlMsgContainer);
} else {
for(OutlookFileAttachment ofa: this.outlookMsgContainer.fetchTrueAttachments()) {
if((ofa.getFilename()!=null && ofa.getFilename().equals(this.lstAttachments.getSelectedValue().toString())) || ((ofa.getLongFilename()!=null && ofa.getLongFilename().equals(this.lstAttachments.getSelectedValue().toString()))))
if((ofa.getFilename()!=null && ofa.getFilename().equals(this.lstAttachments.getSelectedValue().toString())) || ((ofa.getLongFilename()!=null && ofa.getLongFilename().equals(this.lstAttachments.getSelectedValue().toString())))) {
data=ofa.getData();
break;
}
}
}

Expand Down Expand Up @@ -1817,7 +1819,17 @@ private void mnuSaveAsFileActionPerformed(java.awt.event.ActionEvent evt) {//GEN
String selectedFolder = null;
for (Object selected : this.lstAttachments.getSelectedValuesList()) {

byte[] data = EmailUtils.getAttachmentBytes(selected.toString(), this.emlMsgContainer);
byte[] data = null;
if (this.emlMsgContainer != null) {
data = EmailUtils.getAttachmentBytes(selected.toString(), this.emlMsgContainer);
} else {
for (OutlookFileAttachment ofa : this.outlookMsgContainer.fetchTrueAttachments()) {
if ((ofa.getFilename() != null && ofa.getFilename().equals(selected.toString())) || ((ofa.getLongFilename() != null && ofa.getLongFilename().equals(selected.toString())))) {
data = ofa.getData();
break;
}
}
}

String useFolder = userHome;
if (selectedFolder != null) {
Expand Down Expand Up @@ -1903,7 +1915,17 @@ private void mnuSearchSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN

for (Object selected : this.lstAttachments.getSelectedValuesList()) {

byte[] data = EmailUtils.getAttachmentBytes(selected.toString(), this.emlMsgContainer);
byte[] data = null;
if (this.emlMsgContainer != null) {
data = EmailUtils.getAttachmentBytes(selected.toString(), this.emlMsgContainer);
} else {
for (OutlookFileAttachment ofa : this.outlookMsgContainer.fetchTrueAttachments()) {
if ((ofa.getFilename() != null && ofa.getFilename().equals(selected.toString())) || ((ofa.getLongFilename() != null && ofa.getLongFilename().equals(selected.toString())))) {
data = ofa.getData();
break;
}
}
}

String newName = FileUtils.getNewFileName(selected.toString(), true);
if (newName == null) {
Expand Down

0 comments on commit fd1bdd8

Please sign in to comment.