Skip to content

Commit d0405a5

Browse files
committed
NPE unconditionally dereferencing ManifestElement.getDirectiveKeys()
Fixes #2012
1 parent e96c68d commit d0405a5

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/BundleErrorReporter.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -444,19 +444,21 @@ private void validateSingleton(IHeader header, ManifestElement element) {
444444
}
445445
} else {
446446
Enumeration<String> attrKeys = element.getDirectiveKeys();
447-
int length = 0;
448-
String key = null;
449-
while (attrKeys.hasMoreElements()) {
450-
key = attrKeys.nextElement();
451-
length++;
452-
}
453-
if (length == 1) {
454-
String message = NLS.bind(PDECoreMessages.BundleErrorReporter_singletonRequired,
455-
Constants.SINGLETON_DIRECTIVE);
456-
VirtualMarker marker = report(message, header.getLineNumber(), CompilerFlags.ERROR,
457-
PDEMarkerFactory.M_SINGLETON_DIR_CHANGE, PDEMarkerFactory.CAT_FATAL);
458-
addMarkerAttribute(marker, "userDirective", key); //$NON-NLS-1$
459-
return;
447+
if (attrKeys != null) {
448+
int length = 0;
449+
String key = null;
450+
while (attrKeys.hasMoreElements()) {
451+
key = attrKeys.nextElement();
452+
length++;
453+
}
454+
if (length == 1) {
455+
String message = NLS.bind(PDECoreMessages.BundleErrorReporter_singletonRequired,
456+
Constants.SINGLETON_DIRECTIVE);
457+
VirtualMarker marker = report(message, header.getLineNumber(), CompilerFlags.ERROR,
458+
PDEMarkerFactory.M_SINGLETON_DIR_CHANGE, PDEMarkerFactory.CAT_FATAL);
459+
addMarkerAttribute(marker, "userDirective", key); //$NON-NLS-1$
460+
return;
461+
}
460462
}
461463
String message = NLS.bind(PDECoreMessages.BundleErrorReporter_singletonRequired, Constants.SINGLETON_DIRECTIVE);
462464
report(message, header.getLineNumber(), CompilerFlags.ERROR, PDEMarkerFactory.M_SINGLETON_DIR_NOT_SET, PDEMarkerFactory.CAT_FATAL);

0 commit comments

Comments
 (0)