diff --git a/core/src/processing/data/Table.java b/core/src/processing/data/Table.java index e9b221a55..82bf5b11f 100644 --- a/core/src/processing/data/Table.java +++ b/core/src/processing/data/Table.java @@ -1301,22 +1301,24 @@ public class Table { // save us from having to create the entire document in memory again before // writing to the file. So while it's dorky, the outcome is still useful. StringBuilder sanitized = new StringBuilder(); - char[] array = text.toCharArray(); - for (char c : array) { - if (c == '&') { - sanitized.append("&"); - } else if (c == '\'') { - sanitized.append("'"); - } else if (c == '"') { - sanitized.append("""); - } else if (c == '<') { - sanitized.append("<"); - } else if (c == '>') { - sanitized.append("&rt;"); - } else if (c < 32 || c > 127) { - sanitized.append("&#" + ((int) c) + ";"); - } else { - sanitized.append(c); + if (text != null) { + char[] array = text.toCharArray(); + for (char c : array) { + if (c == '&') { + sanitized.append("&"); + } else if (c == '\'') { + sanitized.append("'"); + } else if (c == '"') { + sanitized.append("""); + } else if (c == '<') { + sanitized.append("<"); + } else if (c == '>') { + sanitized.append("&rt;"); + } else if (c < 32 || c > 127) { + sanitized.append("&#" + ((int) c) + ";"); + } else { + sanitized.append(c); + } } }