fix potential memory leak
This commit is contained in:
parent
4e58a588f1
commit
58631d5d8a
1 changed files with 8 additions and 5 deletions
|
@ -108,12 +108,15 @@ namespace EnvyUpdate
|
||||||
{
|
{
|
||||||
// This will fetch the most recent version's tag on GitHub.
|
// This will fetch the most recent version's tag on GitHub.
|
||||||
string updPath = "https://api.github.com/repos/fyr77/envyupdate/releases/latest";
|
string updPath = "https://api.github.com/repos/fyr77/envyupdate/releases/latest";
|
||||||
|
dynamic data = null;
|
||||||
|
|
||||||
WebClient wc = new WebClient();
|
using (var wc = new WebClient())
|
||||||
// Use some user agent to not get 403'd by GitHub.
|
{
|
||||||
wc.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko");
|
// Use some user agent to not get 403'd by GitHub.
|
||||||
string webData = wc.DownloadString(updPath);
|
wc.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko");
|
||||||
dynamic data = JsonConvert.DeserializeObject(webData);
|
string webData = wc.DownloadString(updPath);
|
||||||
|
data = JsonConvert.DeserializeObject(webData);
|
||||||
|
}
|
||||||
|
|
||||||
// I am not catching a possible parsing exception, because I cannot think of any way it could happen.
|
// I am not catching a possible parsing exception, because I cannot think of any way it could happen.
|
||||||
// If there is no internet connection, it should already throw when using the web client.
|
// If there is no internet connection, it should already throw when using the web client.
|
||||||
|
|
Reference in a new issue