changeset 18611:a982d64d1727

indexer-worker: Don't crash if we failed to get mailbox path. Found by Coverity
author Timo Sirainen <tss@iki.fi>
date Sat, 09 May 2015 19:28:46 +0300
parents 7f151aca47ac
children d547eee8a8c7
files src/indexer/master-connection.c
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/indexer/master-connection.c	Sat May 09 19:26:01 2015 +0300
+++ b/src/indexer/master-connection.c	Sat May 09 19:28:46 2015 +0300
@@ -139,14 +139,15 @@
 	ns = mail_namespace_find(user->namespaces, mailbox);
 	box = mailbox_alloc(ns->list, mailbox, 0);
 	ret = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX, &path);
-	if (ret <= 0) {
+	if (ret < 0) {
+		i_error("Getting path to mailbox %s failed: %s",
+			mailbox, mailbox_get_last_error(box, NULL));
 		mailbox_free(&box);
-		if (ret < 0) {
-			i_error("Getting path to mailbox %s failed: %s",
-				mailbox, mailbox_get_last_error(box, NULL));
-			return -1;
-		}
+		return -1;
+	}
+	if (ret == 0) {
 		i_info("Indexes disabled for mailbox %s, skipping", mailbox);
+		mailbox_free(&box);
 		return 0;
 	}
 	ret = 0;