From a7e481619c260ed9fad0589f942f11c9861d2ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Thu, 6 Aug 2015 21:17:52 +0200 Subject: [PATCH] Check for invalid spiros input --- Spiro/Spiro.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Spiro/Spiro.cs b/Spiro/Spiro.cs index 2cd3135..b71a873 100644 --- a/Spiro/Spiro.cs +++ b/Spiro/Spiro.cs @@ -173,7 +173,16 @@ namespace SpiroNet SpiroSegment[] s; int n; - for (n = 0; spiros[n].Type != SpiroPointType.End && spiros[n].Type != SpiroPointType.EndOpenContour; ++n) ; + n = 0; + while (true) + { + if (spiros[n].Type == SpiroPointType.End || spiros[n].Type == SpiroPointType.EndOpenContour) + break; + + // invalid input + if (n >= spiros.Length) + return false; + } if (spiros[n].Type == SpiroPointType.EndOpenContour) ++n;