<<< Date Index >>>     <<< Thread Index >>>

Re: [PATCH 06 of 16] ctx might be null. Check it earlier



>> # HG changeset patch
>> # User Erik Hovland <erik@xxxxxxxxxxx>
>> # Date 1236891080 25200
>> # Branch HEAD
>> # Node ID 43c02f38d2127c88da18495a6c9c7c1bf5e007a7
>> # Parent  d56f727afd7dcb5f95d4d82fa262699c707d8844
>> ctx might be null. Check it earlier.
>
> ctx cannot be NULL I think because mutt_set_flag needs to work on
> messages from an open folder. The check might imply that it can be NULL,
> but that wouldn't make much sense and should be considered a bug.
>
> I think the fix from using 'ctx' variable rather than Context in:
>
>  http://dev.mutt.org/hg/mutt/rev/3279
>
> is just overly eager. Furthermore, there're tons of other calls using
> ctx without prior checking and that never caused trouble so I think it's
> enough to remove the check for ctx to silence analytic tools' warnings.

Fine by me. Patch attached.

E

-- 
Erik Hovland
erik@xxxxxxxxxxx
http://hovland.org/
diff -r 1a0b1e4dec20 -r 27664f1953f7 flags.c
--- a/flags.c   Mon Mar 23 11:56:50 2009 -0700
+++ b/flags.c   Mon Mar 23 12:24:10 2009 -0700
@@ -53,7 +53,7 @@
 #ifdef USE_IMAP
           /* deleted messages aren't treated as changed elsewhere so that the
            * purge-on-sync option works correctly. This isn't applicable here 
*/
-          if (ctx && ctx->magic == M_IMAP)
+          if (ctx->magic == M_IMAP)
           {
             h->changed = 1;
            if (upd_ctx) ctx->changed = 1;