mutt stable branch with some hacks
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix segfault when viewing text attachments in compose menu. (closes #3644)

The segfault was introduced in changeset b9f9e3147eb4. Since decoding
and charset conversion aren't needed for attachments when composing a
message, this patch reverts to just using mutt_save_attachment() to view
"raw data" for text attachments in the compose/send case.

This patch is based on Michael Elkins' patch at
http://dev.mutt.org/trac/attachment/ticket/3644/view_attach_compose_segfault
with just a missing return value check added.

+31 -18
+31 -18
attach.c
··· 504 504 505 505 if (flag == M_AS_TEXT) 506 506 { 507 - /* just let me see the raw data. 508 - * 509 - * Don't use mutt_save_attachment() because we want to perform charset 510 - * conversion since this will be displayed by the internal pager. 511 - */ 512 - STATE decode_state; 507 + /* just let me see the raw data */ 508 + if (fp) 509 + { 510 + /* Viewing from a received message. 511 + * 512 + * Don't use mutt_save_attachment() because we want to perform charset 513 + * conversion since this will be displayed by the internal pager. 514 + */ 515 + STATE decode_state; 513 516 514 - memset(&decode_state, 0, sizeof(decode_state)); 515 - decode_state.fpout = safe_fopen(pagerfile, "w"); 516 - if (!decode_state.fpout) 517 + memset(&decode_state, 0, sizeof(decode_state)); 518 + decode_state.fpout = safe_fopen(pagerfile, "w"); 519 + if (!decode_state.fpout) 520 + { 521 + dprint(1, (debugfile, "mutt_view_attachment:%d safe_fopen(%s) errno=%d %s\n", __LINE__, pagerfile, errno, strerror(errno))); 522 + mutt_perror(pagerfile); 523 + mutt_sleep(1); 524 + goto return_error; 525 + } 526 + decode_state.fpin = fp; 527 + decode_state.flags = M_CHARCONV; 528 + mutt_decode_attachment(a, &decode_state); 529 + if (fclose(decode_state.fpout) == EOF) 530 + dprint(1, (debugfile, "mutt_view_attachment:%d fclose errno=%d %s\n", __LINE__, pagerfile, errno, strerror(errno))); 531 + } 532 + else 517 533 { 518 - dprint(1, (debugfile, "mutt_view_attachment:%d safe_fopen(%s) errno=%d %s\n", __LINE__, pagerfile, errno, strerror(errno))); 519 - mutt_perror(pagerfile); 520 - mutt_sleep(1); 521 - goto return_error; 534 + /* in compose mode, just copy the file. we can't use 535 + * mutt_decode_attachment() since it assumes the content-encoding has 536 + * already been applied 537 + */ 538 + if (mutt_save_attachment(fp, a, pagerfile, 0, NULL)) 539 + goto return_error; 522 540 } 523 - decode_state.fpin = fp; 524 - decode_state.flags = M_CHARCONV; 525 - mutt_decode_attachment(a, &decode_state); 526 - if (fclose(decode_state.fpout) == EOF) 527 - dprint(1, (debugfile, "mutt_view_attachment:%d fclose errno=%d %s\n", __LINE__, pagerfile, errno, strerror(errno))); 528 541 } 529 542 else 530 543 {