Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Rubezhny2020-08-24 19:30:30 -0400
committerJeff Johnston2020-08-25 16:08:45 -0400
commit2b67c0bda992009721965d08ae72d911e3c31bcf (patch)
treeca2755e40521cbc178700ef869b3edc87797c1be /build/org.eclipse.cdt.managedbuilder.core/src/org
parent05c45c0bae9c85b917309712306aadee052f3d8f (diff)
downloadorg.eclipse.cdt-2b67c0bda992009721965d08ae72d911e3c31bcf.tar.gz
org.eclipse.cdt-2b67c0bda992009721965d08ae72d911e3c31bcf.tar.xz
org.eclipse.cdt-2b67c0bda992009721965d08ae72d911e3c31bcf.zip
Bug 418579 - String index out of range: -8
Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com> Change-Id: I02763d18fdf8f9715670b671a7f84f9fe06489ca
Diffstat (limited to 'build/org.eclipse.cdt.managedbuilder.core/src/org')
-rw-r--r--build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java
index dada8d82a19..f37f241e131 100644
--- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java
+++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/AdditionalInput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2019 Intel Corporation and others.
+ * Copyright (c) 2005, 2020 Intel Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
+import java.util.regex.Pattern;
import org.eclipse.cdt.core.cdtvariables.CdtVariableException;
import org.eclipse.cdt.core.settings.model.ICStorageElement;
@@ -493,6 +494,8 @@ public class AdditionalInput implements IAdditionalInput {
return dirs;
}
+ final static Pattern extPattern = Pattern.compile("(?!\\.)(\\d+(\\.\\d+(\\.\\d+)?)?)(?![\\d\\.])$"); //$NON-NLS-1$
+
private URI findLibrary(IToolChain toolChain, final String libName, List<String> dirs) throws CoreException {
final String libSO = getDynamicLibPrefix(toolChain) + libName + '.' + getDynamicLibExtension(toolChain);
final String libA = getStaticLibPrefix(toolChain) + libName + '.' + getStaticLibExtension(toolChain);
@@ -505,15 +508,14 @@ public class AdditionalInput implements IAdditionalInput {
return false;
if (libSO.length() == name.length())
return true; // we don't necessarily have a version extension
- if (name.charAt(libSO.length()) != '.')
- return false;
- String ext = libName.substring(libSO.length() + 1);
- try {
- Integer.parseInt(ext);
- return true;
- } catch (NumberFormatException e) {
+ if (name.length() <= libSO.length() + 1 || name.charAt(libSO.length()) != '.')
return false;
- }
+ String ext = name.substring(libSO.length() + 1);
+
+ // Check the version extension to be in form of "<Major>.<Minor>.<Build>",
+ // for example: "1.10.0", "1.10", "1" are the valid version extensions
+ //
+ return extPattern.matcher(ext).matches();
}
boolean equals(String a, String b) {

Back to the top