From 13f15009712742722a3210c92dd296a2cb514879 Mon Sep 17 00:00:00 2001
From: Steve Brokenshire <sbrokenshire@xestia.co.uk>
Date: Tue, 9 Feb 2016 23:05:20 +0000
Subject: [PATCH] Fixed crash in frmContactEditorOrganisations in Edit mode.

This is caused because no checks were made on the iterator to see if it
was valid or not.
---
 source/contacteditor/frmContactEditorOrganisations.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/source/contacteditor/frmContactEditorOrganisations.cpp b/source/contacteditor/frmContactEditorOrganisations.cpp
index b6c2e19..9aa5f50 100644
--- a/source/contacteditor/frmContactEditorOrganisations.cpp
+++ b/source/contacteditor/frmContactEditorOrganisations.cpp
@@ -239,7 +239,8 @@ void frmContactEditorOrganisations::SetEditorMode(bool EditMode, SectionType Sec
 		
 		striter = OrganisationListSortAsPtr->find(OrganisationListIndex);
 		 
-		if (striter->first == OrganisationListIndex){
+		if (striter->first == OrganisationListIndex && 
+		  striter != OrganisationListSortAsPtr->end()){
 		
 			strValue = striter->second;
 		
@@ -251,7 +252,8 @@ void frmContactEditorOrganisations::SetEditorMode(bool EditMode, SectionType Sec
 		
 		intiter = OrganisationListPrefPtr->find(OrganisationListIndex);		
 		
-		if (intiter->first == OrganisationListIndex && intiter->second > 0){
+		if (intiter->first == OrganisationListIndex && intiter->second > 0 &&
+		  striter != OrganisationListPrefPtr->end()){
 		
 			sliPriority->SetValue(intiter->second);
 			sliPriority->Enable();
-- 
2.39.5