From b5854acf84795f0a7e741a9e6607a629e0cf3905 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Wed, 10 Dec 2003 00:48:57 +0000 Subject: [PATCH] Avoid NULL pointer deference in threading code. --- thread.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/thread.c b/thread.c index b26a7878a..03409ea40 100644 --- 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) -- 2.40.0