Skip to content

Commit a79bc04

Browse files
authored
Merge pull request #2101 from studentmain/master
Fix #2100 NullReference
2 parents e7f33e3 + 9368f44 commit a79bc04

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

shadowsocks-csharp/Model/SysproxyConfig.cs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public SysproxyConfig()
1919
{
2020
UserSettingsRecorded = false;
2121
Flags = "1";
22+
// Watchout, Nullable! See #2100
2223
ProxyServer = "";
2324
BypassList = "";
2425
PacUrl = "";

shadowsocks-csharp/Util/SystemProxy/Sysproxy.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public static class Sysproxy
1616
{
1717
private const string _userWininetConfigFile = "user-wininet.json";
1818

19-
private static string[] _lanIP = {
19+
private readonly static string[] _lanIP = {
2020
"<local>",
2121
"localhost",
2222
"127.*",
@@ -88,10 +88,11 @@ public static void SetIEProxy(bool enable, bool global, string proxyServer, stri
8888
string arguments;
8989
if (enable)
9090
{
91-
List<string> customBypass = new List<string>(_userSettings.BypassList.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
92-
customBypass.AddRange(_lanIP);
93-
string[] realBypassStrings = customBypass.Distinct().ToArray();
94-
string realBypassString = string.Join(";", realBypassStrings);
91+
string customBypassString = _userSettings.BypassList ?? "";
92+
List<string> customBypassList = new List<string>(customBypassString.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries));
93+
customBypassList.AddRange(_lanIP);
94+
string[] realBypassList = customBypassList.Distinct().ToArray();
95+
string realBypassString = string.Join(";", realBypassList);
9596

9697
arguments = global
9798
? $"global {proxyServer} {realBypassString}"
@@ -114,7 +115,6 @@ public static void SetIEProxy(bool enable, bool global, string proxyServer, stri
114115
ExecSysproxy(arguments);
115116
}
116117

117-
118118
// set system proxy to 1 (null) (null) (null)
119119
public static bool ResetIEProxy()
120120
{
@@ -126,7 +126,7 @@ public static bool ResetIEProxy()
126126
// clear system setting
127127
ExecSysproxy("set 1 - - -");
128128
}
129-
catch (Exception e)
129+
catch (Exception)
130130
{
131131
return false;
132132
}

0 commit comments

Comments
 (0)