[armedbear-devel] patch to stop NPE in PATHNAME.WINDOWS.6

Matthew L Daniel mdaniel at gmail.com
Thu May 26 09:47:06 UTC 2011


Hello,

When running `abcl.test' against r13286, I am experiencing a 
NullPointerException caused by the Pathname's URI having a null Path property. 
The patch below fixes this by reporting an error instead of just blindly passing 
it into java.io.File.

  Hope this helps,
  -- /v\atthew

---8<---patch-----8<--
--- a/src/org/armedbear/lisp/Pathname.java
+++ b/src/org/armedbear/lisp/Pathname.java
@@ -356,8 +356,12 @@ public class Pathname extends LispObject {
                                     + "'" + url.toString() + "'"
                                     + ": " + ex.toString()));
                 }
-                File file = new File(uri.getPath());
-                Pathname p = new Pathname(file.getPath());
+                final String uriPath = uri.getPath();
+                if (null == uriPath) {
+                    error(new FileError("The URI has no path: "+uri));
+                }
+                final File file = new File(uriPath);
+                final Pathname p = new Pathname(file.getPath());
                 this.host = p.host;
                 this.device = p.device;
                 this.directory = p.directory;
--->8--end-patch-->8--

---8<--exception-----8<--
; (DEFTEST WINDOWS.4 ...)
; (DEFTEST WINDOWS.5 ...)
; (DEFTEST PATHNAME.WINDOWS.6 ...)
Exception in thread "interpreter" java.lang.NullPointerException
	at java.io.File.<init>(File.java:222)
	at org.armedbear.lisp.Pathname.init(Pathname.java:359)
	at org.armedbear.lisp.Pathname.<init>(Pathname.java:174)
	at org.armedbear.lisp.Pathname.parseNamestring(Pathname.java:1021)
	at org.armedbear.lisp.Stream.readPathname(Stream.java:538)
	at org.armedbear.lisp.LispReader$15.execute(LispReader.java:247)
--->8--end-exception-->8--







More information about the armedbear-devel mailing list