OpenCV Manager crashes with exception (Bug #2660)

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

View File

@ -402,7 +402,13 @@ 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(".");
if (dot == -1 || OpenCVersion.length() == 0)
return "unknown";
else
return OpenCVersion.substring(0, OpenCVersion.length()-1) + "." + return OpenCVersion.substring(0, OpenCVersion.length()-1) + "." +
OpenCVersion.toCharArray()[OpenCVersion.length()-1] + "." + OpenCVersion.toCharArray()[OpenCVersion.length()-1] + "." +
PackageVersion.substring(0, dot) + " rev " + PackageVersion.substring(dot+1); PackageVersion.substring(0, dot) + " rev " + PackageVersion.substring(dot+1);