From 71ba7e0d138b816b4b7b5c0b94990e3e6a868ffc Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Fri, 25 May 2012 13:11:36 +0200 Subject: [PATCH] Check for NULL pointer before passing it into qsort & free --- citadel/modules/fulltext/serv_fulltext.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/citadel/modules/fulltext/serv_fulltext.c b/citadel/modules/fulltext/serv_fulltext.c index 681262b4e..3fa22d781 100644 --- a/citadel/modules/fulltext/serv_fulltext.c +++ b/citadel/modules/fulltext/serv_fulltext.c @@ -415,7 +415,8 @@ void ft_search(int *fts_num_msgs, long **fts_msgs, const char *search_string) { } free(tokens); - qsort(all_msgs, num_all_msgs, sizeof(long), longcmp); + if (all_msgs != NULL) + qsort(all_msgs, num_all_msgs, sizeof(long), longcmp); /* * At this point, if a message appears num_tokens times in the @@ -435,8 +436,8 @@ void ft_search(int *fts_num_msgs, long **fts_msgs, const char *search_string) { } } - - free(all_msgs); + if (all_msgs != NULL) + free(all_msgs); } *fts_num_msgs = num_ret_msgs; -- 2.30.2