From 7735cee871d02215517cb9d91cd552f003ca6a50 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 1 Sep 2014 18:23:42 -0500 Subject: [PATCH] altoslib: Catch a couple null pointers in AltosConfigTD When messing with TD, I hit a couple of paths that could try to dereference null pointers. Check for those. Signed-off-by: Keith Packard --- altosui/AltosConfigTD.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/altosui/AltosConfigTD.java b/altosui/AltosConfigTD.java index 4389e49b..9020ed9d 100644 --- a/altosui/AltosConfigTD.java +++ b/altosui/AltosConfigTD.java @@ -223,8 +223,10 @@ public class AltosConfigTD implements ActionListener { if (!config_version.get().equals("0.0")) break; been_there = true; - config.serial_line.printf("C\n "); - config.serial_line.flush_input(); + if (config != null && config.serial_line != null) { + config.serial_line.printf("C\n "); + config.serial_line.flush_input(); + } } } catch (InterruptedException ie) { } @@ -277,8 +279,10 @@ public class AltosConfigTD implements ActionListener { } void abort() { - serial_line.close(); - serial_line = null; + if (serial_line != null) { + serial_line.close(); + serial_line = null; + } JOptionPane.showMessageDialog(owner, String.format("Connection to \"%s\" failed", device.toShortString()), -- 2.30.2