Re: utime crash
On Tuesday, 23 February 2010 at 10:18, Sean Boudreau wrote:
>
> Hi:
>
> mutt 1.5.20
> I'm getting the following fault on QNX in utime().
>
> #4 0xb031ada9 in utime () from /home/seanb/svn/stage/x86/lib/libc.so.3
> #5 0x080549b9 in mutt_buffy_cleanup (buf=0x0, st=0x8046490) at buffy.c:158
> #6 0x0805b72a in mutt_save_message (h=0x0, delete=1, decode=0, decrypt=0,
> redraw=0x8162a5c) at commands.c:865
> #7 0x08067ef2 in mutt_index_menu () at curs_main.c:1413
> #8 0x08083f46 in main (argc=1, argv=0x80477dc) at main.c:1020
>
> It boils down to the following snippet from mutt_save_message()
>
> need_buffy_cleanup = (ctx.magic == M_MBOX || ctx.magic == M_MMDF);
>
> mx_close_mailbox (&ctx, NULL);
>
> if (need_buffy_cleanup)
> mutt_buffy_cleanup (ctx.path, &st);
>
> mx_close_mailbox() will NULL out ctx.path so utime is
> passed NULL as its first argument. The utime is probably
> failing with EFAULT on other platforms but that's not
> portable (AFAIK). Suggested diff attached.
>
> Regards,
>
> -seanb
>
> +++ mutt-1.5.20/buffy.c
> @@ -145,7 +145,7 @@ void mutt_buffy_cleanup (const char *buf
> if (tmp && !tmp->new)
> mutt_update_mailbox (tmp);
> }
> - else
> + else if (buf != NULL)
> {
> /* fix up the times so buffy won't get confused */
> if (st->st_mtime > st->st_atime)
Thanks for the bug and the diagnosis. Your suggestion will cause
mutt_save_message's attempt to do mutt_buffy_cleanup to silently fail,
so I've applied this patch:
diff --git a/commands.c b/commands.c
--- a/commands.c
+++ b/commands.c
@@ -863,7 +863,7 @@
mx_close_mailbox (&ctx, NULL);
if (need_buffy_cleanup)
- mutt_buffy_cleanup (ctx.path, &st);
+ mutt_buffy_cleanup (buf, &st);
mutt_clear_error ();
return (0);