Bug: RMIR/RMDU crashes on filename without directory
Posted: Sat Nov 23, 2024 5:13 am
To reproduce: start rmir or rmdu from the command line with a file name without directory, like
The program crashed. rmaster,err says:
This is while on the user supplied file name (fileToOpen) first File.parentFile() is preformed (returns null), then on the result File.getParentFile() is done, which of course bombs.
One possible fix would be to replace all getParentFile() by getCanonicFile.getParent(), but there are several of those. A more elegant fix appears to be to canonicalize the file name just when read, i.e.,
Will check in on request.
Code: Select all
java -jar ***.jar Aiwa-CX.rmduCode: Select all
...
java.lang.NullPointerException: Cannot invoke "java.io.File.getAbsolutePath()" because "file" is null
at com.hifiremote.jp1.PropertyFile.setProperty(PropertyFile.java:112)
at com.hifiremote.jp1.Preferences.setUpgradePath(Preferences.java:245)
at com.hifiremote.jp1.KeyMapMaster.loadUpgrade(KeyMapMaster.java:1479)
at com.hifiremote.jp1.RemoteMaster$1.run(RemoteMaster.java:506)
...
One possible fix would be to replace all getParentFile() by getCanonicFile.getParent(), but there are several of those. A more elegant fix appears to be to canonicalize the file name just when read, i.e.,
Code: Select all
Index: src/main/java/com/hifiremote/jp1/RemoteMaster.java
===================================================================
--- src/main/java/com/hifiremote/jp1/RemoteMaster.java (revision 2082)
+++ src/main/java/com/hifiremote/jp1/RemoteMaster.java (working copy)
@@ -358,7 +358,7 @@
File fileToOpen = null;
if ( commandLineArgs.fileName != null )
{
- fileToOpen = new File( commandLineArgs.fileName );
+ fileToOpen = new File( commandLineArgs.fileName ).getCanonicalFile();
if ( hasEnding( commandLineArgs.fileName, upgradeEndings, upgradeImportEndings ) )
{
if ( commandLineArgs.launchRMIR || commandLineArgs.launchRMPB )