Menu

#11 ArrayIndexOutOfBoundsException

open
nobody
None
5
2010-11-25
2010-11-25
Anonymous
No

For empty request like
GET / HTTP/1.1
Server throws ArrayIndexOutOfBoundsException. I suggest following patch for more defensive implementation.

### Eclipse Workspace Patch 1.0
#P xmlvm
Index: src/xmlvm2objc/compat-lib/java/org/xmlvm/iphone/internal/MicroHTTPServer.java
===================================================================
--- src/xmlvm2objc/compat-lib/java/org/xmlvm/iphone/internal/MicroHTTPServer.java (revision 1249)
+++ src/xmlvm2objc/compat-lib/java/org/xmlvm/iphone/internal/MicroHTTPServer.java (working copy)
@@ -60,8 +60,12 @@

String uri = req.split(" ")[1];
String[] args = uri.split("/");
- String cmd = args[1];
- if (cmd.equals("ACC")) {
+
+ String cmd = null;
+ if(args.length > 1) {
+ cmd = args[1];
+ }
+ if ("ACC".equals(cmd)) {
float xAxis = Float.parseFloat(args[2]);
float yAxis = Float.parseFloat(args[3]);
float zAxis = Float.parseFloat(args[4]);

Discussion


Log in to post a comment.