From 1e68d4dffd81e69e2ff740fdf249a696f05e0544 Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Sat, 5 Oct 2013 00:52:27 +0200
Subject: Fix heap-use-after-free bugs reported by asan.

One only showed in netbook-mode. Another got introduced by the impromptu patch.

Change-Id: Id878d001b6bac67f943a86386300c8a0db3bc74e
License: This patch is BSD-licensed, see Documentation/Licenses/BSD-simplified.txt for details.

diff --git a/Swift/QtUI/QtSwift.cpp b/Swift/QtUI/QtSwift.cpp
index e84f9cf..183f64d 100644
--- a/Swift/QtUI/QtSwift.cpp
+++ b/Swift/QtUI/QtSwift.cpp
@@ -251,10 +251,10 @@ QtSwift::~QtSwift() {
 		delete tray;
 	}
 	delete tabs_;
+	delete splitter_;
 	delete settingsHierachy_;
 	delete qtSettings_;
 	delete xmlSettings_;
-	delete splitter_;
 	delete statusCache_;
 	delete uriHandler_;
 	delete dock_;
diff --git a/Swiften/MUC/MUC.cpp b/Swiften/MUC/MUC.cpp
index ff26c86..f85cf8d 100644
--- a/Swiften/MUC/MUC.cpp
+++ b/Swiften/MUC/MUC.cpp
@@ -175,8 +175,8 @@ void MUC::handleIncomingPresence(Presence::ref presence) {
 			std::map<std::string,MUCOccupant>::iterator i = occupants.find(nick);
 			if (i != occupants.end()) {
 				//TODO: part type
-				occupants.erase(i);
 				MUCOccupant occupant = i->second;
+				occupants.erase(i);
 				onOccupantLeft(occupant, type, "");
 			}
 		}
-- 
cgit v0.10.2-6-g49f6