From 7780fe0ce7f5ed3b2473e7fc78e31ab64c6caab1 Mon Sep 17 00:00:00 2001 From: PaulStoffregen Date: Wed, 6 Oct 2021 10:15:52 -0700 Subject: [PATCH] Fix rare Null Pointer Exception when closing Serial Monitor Window --- app/src/processing/app/FifoDocument.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/processing/app/FifoDocument.java b/app/src/processing/app/FifoDocument.java index fa9edee..3cfb922 100644 --- a/app/src/processing/app/FifoDocument.java +++ b/app/src/processing/app/FifoDocument.java @@ -164,10 +164,12 @@ public synchronized void free() { char_head = char_tail = 0; line_head = line_tail = 0; char_buf = null; - for (int i=0; i < line_size; i++) { - line_buf[i] = null; + if (line_buf != null) { + for (int i=0; i < line_size; i++) { + line_buf[i] = null; + } + line_buf = null; } - line_buf = null; newline_offset = null; System.gc(); }