]> granicus.if.org Git - mutt/commitdiff
Avoid NULL pointer deference in threading code.
authorThomas Roessler <roessler@does-not-exist.org>
Wed, 10 Dec 2003 00:48:57 +0000 (00:48 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Wed, 10 Dec 2003 00:48:57 +0000 (00:48 +0000)
thread.c

index b26a7878a0e79f7af4ee2d96e9d0a8209ec0bbce..03409ea4016a6234dc9864f7326cec6c4a45601b 100644 (file)
--- a/thread.c
+++ b/thread.c
@@ -72,7 +72,7 @@ static int need_display_subject (CONTEXT *ctx, HEADER *hdr)
        return (1);
     }
   }
-  
+
   /* if we have no visible parent or previous sibling, display the subject */
   return (1);
 }
@@ -947,16 +947,19 @@ void mutt_sort_threads (CONTEXT *ctx, int init)
   if (!option (OPTSTRICTTHREADS))
     pseudo_threads (ctx);
 
-  ctx->tree = mutt_sort_subthreads (ctx->tree, init);
-
-  /* restore the oldsort order. */
-  Sort = oldsort;
+  if (ctx->tree)
+  {
+    ctx->tree = mutt_sort_subthreads (ctx->tree, init);
 
-  /* Put the list into an array. */
-  linearize_tree (ctx);
+    /* restore the oldsort order. */
+    Sort = oldsort;
+    
+    /* Put the list into an array. */
+    linearize_tree (ctx);
 
-  /* Draw the thread tree. */
-  mutt_draw_tree (ctx);
+    /* Draw the thread tree. */
+    mutt_draw_tree (ctx);
+  }
 }
 
 static HEADER *find_virtual (THREAD *cur, int reverse)