From 56191e3d34ece94710d33077265b36c2ddd8a08f Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 25 Nov 2014 15:58:37 -0800 Subject: [PATCH] Guard against bad eeprom return values. --- EeProm/EePromRepetierParameter.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/EeProm/EePromRepetierParameter.cs b/EeProm/EePromRepetierParameter.cs index 333906829..b73f79bad 100644 --- a/EeProm/EePromRepetierParameter.cs +++ b/EeProm/EePromRepetierParameter.cs @@ -50,12 +50,18 @@ namespace MatterHackers.MatterControl.EeProm public void update(string line) { - string[] lines = line.Substring(4).Split(' '); - int.TryParse(lines[0], out type); - int.TryParse(lines[1], out position); - val = lines[2]; - description = line.Substring(7 + lines[0].Length + lines[1].Length + lines[2].Length); - changed = false; + if (line.Length > 4) + { + string[] lines = line.Substring(4).Split(' '); + if (lines.Length > 2) + { + int.TryParse(lines[0], out type); + int.TryParse(lines[1], out position); + val = lines[2]; + description = line.Substring(7 + lines[0].Length + lines[1].Length + lines[2].Length); + changed = false; + } + } } public void save()