Browse Source

bugfix for empty string in GhostPorts array and services fragment

Daniel Lazar 10 years ago
parent
commit
216463c3b3

+ 3 - 1
src/de/tudarmstadt/informatik/hostage/model/Profile.java

@@ -154,7 +154,9 @@ public class Profile implements JSONSerializable<Profile> {
 		Integer[] ports = new Integer[splits.length];
 
 		for(int i=0; i<splits.length; i++){
-			ports[i] = Integer.valueOf(splits[i]);
+            if(!splits[i].equals("")) {
+                ports[i] = Integer.valueOf(splits[i]);
+            }
 		}
 
 		return ports;

+ 11 - 6
src/de/tudarmstadt/informatik/hostage/ui2/adapter/ServicesListAdapter.java

@@ -158,8 +158,10 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
                                    if(item.protocol.equals("GHOST")) {
                                        mGhostPorts = mProfile.getGhostPorts();
                                        for(Integer port: mGhostPorts){
-                                           if(MainActivity.getInstance().getHostageService().isRunning("GHOST",port)){
-                                               MainActivity.getInstance().getHostageService().stopListener("GHOST", port);
+                                           if(port != null) {
+                                               if(MainActivity.getInstance().getHostageService().isRunning("GHOST",port)){
+                                                   MainActivity.getInstance().getHostageService().stopListener("GHOST", port);
+                                               }
                                            }
                                        }
                                        buttonView.setChecked(false);
@@ -188,10 +190,13 @@ public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
             mGhostPorts = mProfile.getGhostPorts();
 
             boolean ghostActive = false;
-
-            for(Integer port: mGhostPorts){
-                if(MainActivity.getInstance().getHostageService().isRunning("GHOST",port)){
-                    ghostActive = true;
+            if(mGhostPorts.length != 0) {
+                for (Integer port : mGhostPorts) {
+                    if(port != null){
+                        if (MainActivity.getInstance().getHostageService().isRunning("GHOST", port)) {
+                            ghostActive = true;
+                        }
+                    }
                 }
             }
             if(ghostActive){