#2533 NPE in fwt:TextChange.toStr()

SlimerDude Tue 19 Apr 2016

The oldText and newText fields in TextChange are nullable, but the toStr method doesn't guard against this. A quick patch is given below:

diff -r 73783f732179 src/fwt/fan/TextWidget.fan
--- a/src/fwt/fan/TextWidget.fan	Wed Apr 13 11:44:09 2016 -0400
+++ b/src/fwt/fan/TextWidget.fan	Tue Apr 19 20:59:49 2016 +0100
@@ -211,8 +211,8 @@
 
   override Str toStr()
   {
-    o := oldText.size < 10 ? oldText : oldText[0..<10] + "..<"
-    n := newText.size < 10 ? newText : newText[0..<10] + "..<"
+    o := (oldText ?: "").size < 10 ? (oldText ?: "") : oldText[0..<10] + "..<"
+    n := (newText ?: "").size < 10 ? (newText ?: "") : newText[0..<10] + "..<"
     return "startOffset=$startOffset startLine=$startLine " +
            "newText=$n.toCode oldText=$o.toCode " +
            "oldNumNewlines=$oldNumNewlines newNumNewlines=$newNumNewlines"

brian Tue 19 Apr 2016

thanks for reporting, I pushed a fix

Login or Signup to reply.