OpenCV Manager crashes with exception (Bug )

String checking and range cheching added.
This commit is contained in:
Alexander Smorkalov 2012-12-24 18:05:48 +04:00
parent 014a500f79
commit 064bf167ad

@ -402,10 +402,16 @@ public class ManagerActivity extends Activity
protected String NormalizeVersion(String OpenCVersion, String PackageVersion) protected String NormalizeVersion(String OpenCVersion, String PackageVersion)
{ {
if (OpenCVersion == null || PackageVersion == null)
return "unknown";
int dot = PackageVersion.indexOf("."); int dot = PackageVersion.indexOf(".");
return OpenCVersion.substring(0, OpenCVersion.length()-1) + "." + if (dot == -1 || OpenCVersion.length() == 0)
OpenCVersion.toCharArray()[OpenCVersion.length()-1] + "." + return "unknown";
PackageVersion.substring(0, dot) + " rev " + PackageVersion.substring(dot+1); else
return OpenCVersion.substring(0, OpenCVersion.length()-1) + "." +
OpenCVersion.toCharArray()[OpenCVersion.length()-1] + "." +
PackageVersion.substring(0, dot) + " rev " + PackageVersion.substring(dot+1);
} }
protected String ConvertPackageName(String Name, String Version) protected String ConvertPackageName(String Name, String Version)