From bfe4ed9895f2b24077754ae449972ba21b4d0652 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sat, 24 Sep 2016 07:05:29 +0000
Subject: [PATCH] fix crash

---
 contrib/mobile/iOS/Onelab/Parameter.mm | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/contrib/mobile/iOS/Onelab/Parameter.mm b/contrib/mobile/iOS/Onelab/Parameter.mm
index 0a21300bb8..43ff566713 100644
--- a/contrib/mobile/iOS/Onelab/Parameter.mm
+++ b/contrib/mobile/iOS/Onelab/Parameter.mm
@@ -78,7 +78,7 @@
                                 delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil
                        otherButtonTitles:nil];
   std::vector<std::string> choices = string[0].getChoices();
-  for(int i=0;i<choices.size();i++)
+  for(int i = 0; i < choices.size(); i++)
     [popupSelectValue addButtonWithTitle:[Utils getStringFromCString:choices[i].c_str()]];
   [popupSelectValue addButtonWithTitle:@"Cancel"];
   [popupSelectValue setCancelButtonIndex:popupSelectValue.numberOfButtons - 1];
@@ -90,11 +90,12 @@
   std::vector<onelab::string> string;
   onelab::server::instance()->get(string, [name UTF8String]);
   if(string.size() < 1) return;
-  if(buttonIndex > string[0].getChoices().size() - 1) return; // cancel
-  std::string selected = string[0].getChoices()[buttonIndex];
-  string[0].setValue(selected);
-  onelab::server::instance()->set(string[0]);
-  [super editValue];
+  if(buttonIndex < string[0].getChoices().size()){
+    std::string selected = string[0].getChoices()[buttonIndex];
+    string[0].setValue(selected);
+    onelab::server::instance()->set(string[0]);
+    [super editValue];
+  }
 }
 
 -(void)refresh
-- 
GitLab