Skip to content

Commit

Permalink
prevent assertion in p_string_erase
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul J Stevens committed Jan 10, 2016
1 parent bd6f156 commit 9b4bf84
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/dm_imapsession.c
Expand Up @@ -870,19 +870,20 @@ static void _imap_send_part(ImapSession *self, GMimeObject *part, body_fetch *bo
} else { } else {
char *tmp = imap_get_logical_part(part,type); char *tmp = imap_get_logical_part(part,type);
String_T str = p_string_new(self->pool, tmp); String_T str = p_string_new(self->pool, tmp);
size_t len = p_string_len(str);
g_free(tmp); g_free(tmp);


if (p_string_len(str) < 1) { if (len < 1) {
dbmail_imap_session_buff_printf(self, "] NIL"); dbmail_imap_session_buff_printf(self, "] NIL");
} else { } else {
uint64_t cnt = 0; uint64_t cnt = 0;
if (bodyfetch->octetcnt > 0) { if (bodyfetch->octetcnt > 0) {
cnt = get_dumpsize(bodyfetch, p_string_len(str)); cnt = get_dumpsize(bodyfetch, len);
dbmail_imap_session_buff_printf(self, "]<%" PRIu64 "> {%" PRIu64 "}\r\n", bodyfetch->octetstart, cnt); dbmail_imap_session_buff_printf(self, "]<%" PRIu64 "> {%" PRIu64 "}\r\n", bodyfetch->octetstart, cnt);
p_string_erase(str,0,bodyfetch->octetstart); p_string_erase(str,0,min(bodyfetch->octetstart,len));
p_string_truncate(str,cnt); p_string_truncate(str,cnt);
} else { } else {
dbmail_imap_session_buff_printf(self, "] {%" PRIu64 "}\r\n", p_string_len(str)); dbmail_imap_session_buff_printf(self, "] {%" PRIu64 "}\r\n", len);
} }
dbmail_imap_session_buff_printf(self,"%s", p_string_str(str)); dbmail_imap_session_buff_printf(self,"%s", p_string_str(str));
} }
Expand Down

0 comments on commit 9b4bf84

Please sign in to comment.