mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 19:22:53 +01:00
Fix exceptional resource leak CID18207
This commit is contained in:
parent
82eeb00413
commit
1020fe7b3f
@ -378,13 +378,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
public static Encoding GetScreenScrapingEncoding(string languagePair)
|
||||
{
|
||||
WebClient webClient = null;
|
||||
try
|
||||
{
|
||||
string url = String.Format("http://translate.google.com/?hl=en&eotf=1&sl={0}&tl={1}&q={2}", languagePair.Substring(0, 2), languagePair.Substring(3), "123 456");
|
||||
var webClient = new WebClient();
|
||||
webClient = new WebClient();
|
||||
webClient.Proxy = Utilities.GetProxy();
|
||||
string result = webClient.DownloadString(url).ToLower();
|
||||
webClient.Dispose();
|
||||
int idx = result.IndexOf("charset", StringComparison.Ordinal);
|
||||
int end = result.IndexOf('"', idx + 8);
|
||||
string charset = result.Substring(idx, end - idx).Replace("charset=", string.Empty);
|
||||
@ -394,6 +394,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
return Encoding.Default;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (webClient != null)
|
||||
{
|
||||
webClient.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user