diff -up mutt-1.5.21/imap/imap.c.syncdebug mutt-1.5.21/imap/imap.c
--- mutt-1.5.21/imap/imap.c.syncdebug	2012-03-27 10:05:44.978962551 +0200
+++ mutt-1.5.21/imap/imap.c	2012-03-27 10:05:54.223252267 +0200
@@ -1128,7 +1128,7 @@ static int sync_helper (IMAP_DATA* idata
 
   char buf[LONG_STRING];
 
-  if (!mutt_bit_isset (idata->ctx->rights, right))
+  if (!idata->ctx || !mutt_bit_isset (idata->ctx->rights, right))
     return 0;
 
   if (right == M_ACL_WRITE && !imap_has_flag (idata->flags, name))
