mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 415789: NPE in ScannerConfigBuilder
An implementation of IEnvironmentVariable is returning null for its key or value. The javadoc on this interface doesn't mention null, which I guess makes it a valid value. This patch checks the result before trying to put it into an instance of java.util.Properties. Change-Id: Ic04ddd72dfb558ca403b549b64847c3437971407 Signed-off-by: Andrew Eidsness <andrewe@jfront.com> Reviewed-on: https://git.eclipse.org/r/15820 Reviewed-by: Andrew Gvozdev <angvoz.dev@gmail.com> IP-Clean: Andrew Gvozdev <angvoz.dev@gmail.com> Tested-by: Andrew Gvozdev <angvoz.dev@gmail.com>
This commit is contained in:
parent
af5a14ac6d
commit
5dbcc8ec21
3 changed files with 11 additions and 5 deletions
|
@ -171,8 +171,13 @@ public class ScannerConfigBuilder extends ACBuilder {
|
|||
ICConfigurationDescription cfgDes = ManagedBuildManager.getDescriptionForConfiguration(cfg);
|
||||
IEnvironmentVariableManager mngr = CCorePlugin.getDefault().getBuildEnvironmentManager();
|
||||
IEnvironmentVariable[] vars = mngr.getVariables(cfgDes, true);
|
||||
|
||||
for(int i = 0; i < vars.length; i++) {
|
||||
envProps.setProperty(vars[i].getName(), vars[i].getValue());
|
||||
if (vars[i] != null
|
||||
&& vars[i].getName() != null) {
|
||||
String value = vars[i].getValue();
|
||||
envProps.setProperty(vars[i].getName(), value == null ? "" : value);
|
||||
}
|
||||
}
|
||||
|
||||
return envProps;
|
||||
|
|
|
@ -50,7 +50,7 @@ public interface IConfigurationEnvironmentVariableSupplier {
|
|||
* and the provider in turn calls that supplier again. Also the supplier should not know anything
|
||||
* about the environment variables defined for the higher levels.
|
||||
* @return The array of IBuildEnvironmentVariable that represents the environment variables.
|
||||
* If the array contains any {@code null} it will be ignored.
|
||||
* The array may contain {@code null} values.
|
||||
*/
|
||||
IBuildEnvironmentVariable[] getVariables(IConfiguration configuration, IEnvironmentVariableProvider provider);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ public interface IEnvironmentVariableManager{
|
|||
*
|
||||
*
|
||||
* @return the reference to the IBuildEnvironmentVariable interface representing
|
||||
* the variable of a given name
|
||||
* the variable of a given name or null
|
||||
* @param name environment variable name
|
||||
* if environment variable names are case insensitive in the current OS,
|
||||
* the environment variable provider will query the getVariable method of suppliers always
|
||||
|
@ -52,7 +52,8 @@ public interface IEnvironmentVariableManager{
|
|||
* the environment variable provider will remove the duplicates of the variables if their names
|
||||
* differ only by case
|
||||
*
|
||||
* @return the array of IBuildEnvironmentVariable that represents the environment variables
|
||||
* @return the array of IBuildEnvironmentVariable that represents the environment variables (the
|
||||
* array may contain null values)
|
||||
*/
|
||||
public IEnvironmentVariable[] getVariables(ICConfigurationDescription cfg, boolean resolveMacros);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue