From 3391c23abd3235b300a17bde3c71bc1830810290 Mon Sep 17 00:00:00 2001 From: idk Date: Sun, 20 Feb 2022 20:29:47 -0500 Subject: [PATCH] Null check path_override --- java/net/i2p/router/WinLauncher.java | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/java/net/i2p/router/WinLauncher.java b/java/net/i2p/router/WinLauncher.java index 7c4682b..61fe6c2 100644 --- a/java/net/i2p/router/WinLauncher.java +++ b/java/net/i2p/router/WinLauncher.java @@ -97,12 +97,14 @@ public class WinLauncher { private static File selectHome() { // throws Exception { String path_override = System.getenv("I2P_CONFIG"); - File path = new File(path_override); - if (path.exists()) { - if (path.isDirectory()) - return path.getAbsoluteFile(); - else - throw new RuntimeException("I2P is not a directory: " + path); + if (path_override != null) { + File path = new File(path_override); + if (path != null && path.exists()) { + if (path.isDirectory()) + return path.getAbsoluteFile(); + else + throw new RuntimeException("I2P_CONFIG is not a directory: " + path); + } } if (SystemVersion.isWindows()) { File home = new File(System.getProperty("user.home")); @@ -122,12 +124,14 @@ public class WinLauncher { private static File selectProgramFile() { String path_override = System.getenv("I2P"); - File path = new File(path_override); - if (path.exists()) { - if (path.isDirectory()) - return path.getAbsoluteFile(); - else - throw new RuntimeException("I2P is not a directory: " + path); + if (path_override != null) { + File path = new File(path_override); + if (path.exists()) { + if (path.isDirectory()) + return path.getAbsoluteFile(); + else + throw new RuntimeException("I2P is not a directory: " + path); + } } if (SystemVersion.isWindows()) { File jrehome = new File(System.getProperty("java.home"));