Skip to content

Commit

Permalink
jmap_mail.c:_email_get_headers() silence clang static analyzer
Browse files Browse the repository at this point in the history
It thinks part is NULL and then part->date is dereferenced.
  • Loading branch information
dilyanpalauzov committed Aug 18, 2023
1 parent bb6a880 commit 84b75d0
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions imap/jmap_mail.c
Original file line number Diff line number Diff line change
Expand Up @@ -7178,7 +7178,6 @@ static int _email_get_headers(jmap_req_t *req __attribute__((unused)),
}

/* The following fields are all read from the body-part structure */
const struct body *part = NULL;
if (jmap_wantprop(props, "messageId") ||
jmap_wantprop(props, "inReplyTo") ||
jmap_wantprop(props, "from") ||
Expand All @@ -7187,6 +7186,7 @@ static int _email_get_headers(jmap_req_t *req __attribute__((unused)),
jmap_wantprop(props, "bcc") ||
jmap_wantprop(props, "subject") ||
jmap_wantprop(props, "sentAt")) {
const struct body *part;
if (msg->rfc822part) {
part = msg->rfc822part->subpart;
}
Expand All @@ -7195,46 +7195,46 @@ static int _email_get_headers(jmap_req_t *req __attribute__((unused)),
if (r) return r;
part = msg->part0;
}
}
/* messageId */
if (jmap_wantprop(props, "messageId")) {
json_object_set_new(email, "messageId",
jmap_header_as_messageids(part->message_id));
}
/* inReplyTo */
if (jmap_wantprop(props, "inReplyTo")) {
json_object_set_new(email, "inReplyTo",
jmap_header_as_messageids(part->in_reply_to));
}
/* from */
if (jmap_wantprop(props, "from")) {
json_object_set_new(email, "from",
jmap_emailaddresses_from_addr(part->from, HEADER_FORM_ADDRESSES));
}
/* to */
if (jmap_wantprop(props, "to")) {
json_object_set_new(email, "to",
jmap_emailaddresses_from_addr(part->to, HEADER_FORM_ADDRESSES));
}
/* cc */
if (jmap_wantprop(props, "cc")) {
json_object_set_new(email, "cc",
jmap_emailaddresses_from_addr(part->cc, HEADER_FORM_ADDRESSES));
}
/* bcc */
if (jmap_wantprop(props, "bcc")) {
json_object_set_new(email, "bcc",
jmap_emailaddresses_from_addr(part->bcc, HEADER_FORM_ADDRESSES));
}
/* subject */
if (jmap_wantprop(props, "subject")) {
json_object_set_new(email, "subject",
jmap_header_as_text(part->subject));
}
/* sentAt */
if (jmap_wantprop(props, "sentAt")) {
json_object_set_new(email, "sentAt",
jmap_header_as_date(part->date));
/* messageId */
if (jmap_wantprop(props, "messageId")) {
json_object_set_new(email, "messageId",
jmap_header_as_messageids(part->message_id));
}
/* inReplyTo */
if (jmap_wantprop(props, "inReplyTo")) {
json_object_set_new(email, "inReplyTo",
jmap_header_as_messageids(part->in_reply_to));
}
/* from */
if (jmap_wantprop(props, "from")) {
json_object_set_new(email, "from",
jmap_emailaddresses_from_addr(part->from, HEADER_FORM_ADDRESSES));
}
/* to */
if (jmap_wantprop(props, "to")) {
json_object_set_new(email, "to",
jmap_emailaddresses_from_addr(part->to, HEADER_FORM_ADDRESSES));
}
/* cc */
if (jmap_wantprop(props, "cc")) {
json_object_set_new(email, "cc",
jmap_emailaddresses_from_addr(part->cc, HEADER_FORM_ADDRESSES));
}
/* bcc */
if (jmap_wantprop(props, "bcc")) {
json_object_set_new(email, "bcc",
jmap_emailaddresses_from_addr(part->bcc, HEADER_FORM_ADDRESSES));
}
/* subject */
if (jmap_wantprop(props, "subject")) {
json_object_set_new(email, "subject",
jmap_header_as_text(part->subject));
}
/* sentAt */
if (jmap_wantprop(props, "sentAt")) {
json_object_set_new(email, "sentAt",
jmap_header_as_date(part->date));
}
}

return r;
Expand Down

0 comments on commit 84b75d0

Please sign in to comment.