Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit f836a22

Browse files
committed
Make TheVersion more resilient to invalid data
1 parent fe91b7c commit f836a22

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/GitHub.Api/Primitives/TheVersion.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,14 @@ private TheVersion Initialize(string theVersion)
5757
special = null;
5858
parts = 0;
5959

60-
if (String.IsNullOrEmpty(theVersion))
61-
return this;
62-
6360
intParts = new int[PART_COUNT];
6461
stringParts = new string[PART_COUNT];
65-
6662
for (var i = 0; i < PART_COUNT; i++)
6763
stringParts[i] = intParts[i].ToString();
6864

65+
if (String.IsNullOrEmpty(theVersion))
66+
return this;
67+
6968
var match = regex.Match(theVersion);
7069
if (!match.Success)
7170
{
@@ -195,9 +194,9 @@ public bool Equals(TheVersion other)
195194
{
196195
if (lhs.Version == rhs.Version)
197196
return false;
198-
if (String.IsNullOrEmpty(lhs.Version))
197+
if (!lhs.initialized)
199198
return false;
200-
if (String.IsNullOrEmpty(rhs.Version))
199+
if (!rhs.initialized)
201200
return true;
202201

203202
for (var i = 0; i < lhs.parts && i < rhs.parts; i++)

0 commit comments

Comments
 (0)