Skip to content

Commit 8584197

Browse files
committed
fix possible NPE
1 parent 6c0266b commit 8584197

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

graalpython/com.oracle.graal.python.shell/src/com/oracle/graal/python/shell/GraalPythonLD.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ private void parseOptions(String[] args) {
108108
List<String> bcFiles = searchLib(libraryDirs, arg.substring(2));
109109
for (String bcFile : bcFiles) {
110110
try {
111-
if (Files.probeContentType(Paths.get(bcFile)).contains(LLVM_IR_BITCODE)) {
111+
String contentType = Files.probeContentType(Paths.get(bcFile));
112+
if (contentType != null && contentType.contains(LLVM_IR_BITCODE)) {
112113
logV("library input:", bcFile);
113114
addFile(bcFile);
114115
} else {
@@ -245,7 +246,8 @@ private Collection<? extends String> arMembers(String path) throws IOException,
245246
// seems ok to emulate this at least for the very common case of ar archives with symbol
246247
// definitions that overlap what's defined in explicitly include .o files
247248
outer: for (String f : members) {
248-
if (Files.probeContentType(Paths.get(f)).contains(LLVM_IR_BITCODE)) {
249+
String contentType = Files.probeContentType(Paths.get(f));
250+
if (contentType != null && contentType.contains(LLVM_IR_BITCODE)) {
249251
HashSet<String> definedFuncs = new HashSet<>();
250252
HashSet<String> definedGlobals = new HashSet<>();
251253

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonFileDetector.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
public final class PythonFileDetector extends FileTypeDetector {
4848
@Override
4949
public String probeContentType(Path path) throws IOException {
50-
if (path.getFileName().toString().endsWith(".py")) {
50+
Path fileName = path.getFileName();
51+
if (fileName != null && fileName.toString().endsWith(".py")) {
5152
return PythonLanguage.MIME_TYPE;
5253
}
5354
return null;

0 commit comments

Comments
 (0)