diff --git a/CHANGELOG.md b/CHANGELOG.md
index d1d332acba..9693453575 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -31,6 +31,7 @@ All notable changes to this project will be documented in this file.
- [GUI] Fix crash at startup on Windows risen in #2536 (#2557 by: HebaruSan; reviewed: Olympic1)
- [Core] Allow game version of "any" with a vref (#2553 by: HebaruSan; reviewed: Olympic1)
- [Core] Fix null ref exception when repo has empty ckan file (#2549 by: HebaruSan; reviewed: Olympic1)
+- [Multiple] Avoid null ksp_version in Netkan (#2558 by: HebaruSan; reviewed: politas)
## v1.25.3 (Woomera)
diff --git a/Core/Versioning/KspVersion.cs b/Core/Versioning/KspVersion.cs
index 6cddd0721e..afd4390065 100644
--- a/Core/Versioning/KspVersion.cs
+++ b/Core/Versioning/KspVersion.cs
@@ -94,6 +94,19 @@ public bool IsAny
get { return !IsMajorDefined && !IsMinorDefined && !IsPatchDefined && !IsBuildDefined; }
}
+ ///
+ /// Check whether a version is null or Any.
+ /// We group them here because they mean the same thing.
+ ///
+ /// The version to check
+ ///
+ /// True if null or Any, false otherwise
+ ///
+ public static bool IsNullOrAny(KspVersion v)
+ {
+ return v == null || v.IsAny;
+ }
+
///
/// Initialize a new instance of the class with all components unspecified.
///
diff --git a/Netkan/Transformers/AvcTransformer.cs b/Netkan/Transformers/AvcTransformer.cs
index e3171baef1..23068606a8 100644
--- a/Netkan/Transformers/AvcTransformer.cs
+++ b/Netkan/Transformers/AvcTransformer.cs
@@ -119,16 +119,16 @@ public static void ApplyVersions(JObject json, AvcVersion avc)
var kspMins = new List();
var kspMaxes = new List();
- if (existingKspMin != null)
+ if (!KspVersion.IsNullOrAny(existingKspMin))
kspMins.Add(existingKspMin);
- if (avcKspMin != null)
+ if (!KspVersion.IsNullOrAny(avcKspMin))
kspMins.Add(avcKspMin);
- if (existingKspMax != null)
+ if (!KspVersion.IsNullOrAny(existingKspMax))
kspMaxes.Add(existingKspMax);
- if (avcKspMax != null)
+ if (!KspVersion.IsNullOrAny(avcKspMax))
kspMaxes.Add(avcKspMax);
var kspMin = kspMins.Any() ? kspMins.Min() : null;