1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Bug 418579 - String index out of range: -8

Signed-off-by: Victor Rubezhny <vrubezhny@redhat.com>
Change-Id: I02763d18fdf8f9715670b671a7f84f9fe06489ca
This commit is contained in:
Victor Rubezhny 2020-08-25 01:30:30 +02:00 committed by Jeff Johnston
parent 05c45c0bae
commit 2b67c0bda9

View file

@ -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()) != '.')
if (name.length() <= libSO.length() + 1 || name.charAt(libSO.length()) != '.')
return false;
String ext = libName.substring(libSO.length() + 1);
try {
Integer.parseInt(ext);
return true;
} catch (NumberFormatException e) {
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) {