Merge pull request #3184 from silverwolfg11/path-null-check

Null check for path environment variable.
This commit is contained in:
mikeprimm 2020-12-30 18:48:17 -06:00 committed by GitHub
commit e879ed7e41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -438,7 +438,12 @@ public class DynmapCore implements DynmapCommonAPI {
} }
private String findExecutableOnPath(String fname) { private String findExecutableOnPath(String fname) {
for (String dirname : System.getenv("PATH").split(File.pathSeparator)) { String path = System.getenv("PATH");
// Fast-fail if path is null.
if (path == null)
return null;
for (String dirname : path.split(File.pathSeparator)) {
File file = new File(dirname, fname); File file = new File(dirname, fname);
if (file.isFile() && file.canExecute()) { if (file.isFile() && file.canExecute()) {
return file.getAbsolutePath(); return file.getAbsolutePath();