From ebd42c50a953c5e322ef3de696b128d6114bfcc9 Mon Sep 17 00:00:00 2001 From: J Wyman Date: Tue, 1 Aug 2017 14:11:32 -0400 Subject: [PATCH] Add null check before using path/ext values. --- Microsoft.Alm.Git/Where.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Microsoft.Alm.Git/Where.cs b/Microsoft.Alm.Git/Where.cs index 054b2bf..381e394 100644 --- a/Microsoft.Alm.Git/Where.cs +++ b/Microsoft.Alm.Git/Where.cs @@ -49,6 +49,13 @@ namespace Microsoft.Alm.Git string pathext = Environment.GetEnvironmentVariable("PATHEXT"); string envpath = Environment.GetEnvironmentVariable("PATH"); + if (string.IsNullOrEmpty(pathext) || string.IsNullOrEmpty(envpath)) + { + // The user is likely hosed, or a poorly crafted test case - eitherway avoid NRE from the .Split call. + path = null; + return false; + } + string[] exts = pathext.Split(';'); string[] paths = envpath.Split(';');