From be6fd0b4b580d81bfe33975c28ee7a939d6c6723 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Remko=20Tron=C3=A7on?= <git@el-tramo.be>
Date: Sat, 10 Nov 2012 15:00:45 +0100
Subject: Don't crash on login with pending subscription events.

Change-Id: I8459b36c92703d5cfc877a6cdd92281541d8df3a

diff --git a/Swift/Controllers/XMPPEvents/EventController.cpp b/Swift/Controllers/XMPPEvents/EventController.cpp
index 9841923..d84dfe3 100644
--- a/Swift/Controllers/XMPPEvents/EventController.cpp
+++ b/Swift/Controllers/XMPPEvents/EventController.cpp
@@ -34,7 +34,8 @@ void EventController::handleIncomingEvent(boost::shared_ptr<StanzaEvent> sourceE
 
 	/* If it's a duplicate subscription request, remove the previous request first */
 	if (subscriptionEvent) {
-		foreach(boost::shared_ptr<StanzaEvent> existingEvent, events_) {
+		EventList existingEvents(events_);
+		foreach(boost::shared_ptr<StanzaEvent> existingEvent, existingEvents) {
 			boost::shared_ptr<SubscriptionRequestEvent> existingSubscriptionEvent = boost::dynamic_pointer_cast<SubscriptionRequestEvent>(existingEvent);
 			if (existingSubscriptionEvent) {
 				if (existingSubscriptionEvent->getJID() == subscriptionEvent->getJID()) {
-- 
cgit v0.10.2-6-g49f6