davemckain / snuggletex

Ancient and somewhat pathological LaTeX parser written in Java
Other
7 stars 4 forks source link

Avoid NPE exception #2

Closed axkr closed 1 year ago

axkr commented 1 year ago

In this line the FrozenSlice object is assigned a null value:

If we want to print the error log the InputError may throw an NPE exception.

This patch can avoid the NPE:

 package uk.ac.ed.ph.snuggletex;
...

...
-
 /**
  * Encapsulates an error in the LaTeX input, providing information about what the error is and where
  * it occurred.
@@ -73,7 +72,7 @@
         + "(errorCode="
         + errorCode.toString()
         + ",slice="
-        + slice.toString()
+        + (slice == null ? "null" : slice.toString())
         + ",arguments="
         + Arrays.toString(arguments)
         + ")";
davemckain commented 1 year ago

Hi @axkr. Many thanks for reporting this bug. I've just committed a fix to the development_1_2_x branch.