[neomutt-devel] [PATCH] Make the use of m instead of ctx consistent in hook.c

Richard Russon rich at flatcap.org
Sun Dec 2 13:07:05 CET 2018


> This should prevent for segfaults creating new mails.

Sorry Elimar, that doesn't work.

Some other functions have been converted to use Mailbox rather than
Context, but here we can't do that.

> -static int addr_hook(char *path, size_t pathlen, int type, struct Context *ctx,
> +static int addr_hook(char *path, size_t pathlen, int type, struct Context *m,

Here, you change its name, but not its type...
But later we see that we need both ctx->mailbox and plain ctx.

> if ((mutt_pattern_exec(hook->pattern, 0, ctx->mailbox, e, &cache) > 0) ^

> mutt_make_string_flags(path, pathlen, hook->command, ctx, e, MUTT_FORMAT_PLAIN);

To prevent the crash, I've done this, instead:

diff --git i/hook.c w/hook.c
index 743189e93..d2922dd61 100644
--- i/hook.c
+++ w/hook.c
@@ -502,8 +502,8 @@ static int addr_hook(char *path, size_t pathlen, int type, struct Context *ctx,
 
     if (hook->type & type)
     {
-      if ((mutt_pattern_exec(hook->pattern, 0, ctx->mailbox, e, &cache) > 0) ^
-          hook->regex.not)
+      struct Mailbox *m = ctx ? ctx->mailbox : NULL;
+      if ((mutt_pattern_exec(hook->pattern, 0, m, e, &cache) > 0) ^ hook->regex.not)
       {
         mutt_make_string_flags(path, pathlen, hook->command, ctx, e, MUTT_FORMAT_PLAIN);
         return 0;

Many of the patterns still require access to the Context, a Menu and
other GUI resources.  Hopefully, we can split them up at some point.

Cheers,
    Rich / FlatCap
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mailman.neomutt.org/pipermail/neomutt-devel-neomutt.org/attachments/20181202/9e026a2a/attachment.sig>


More information about the neomutt-devel mailing list