Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/duplicati/duplicati.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwarwickmm <warwickmm@users.noreply.github.com>2020-12-28 01:33:12 +0300
committerGitHub <noreply@github.com>2020-12-28 01:33:12 +0300
commit45c4f865e8b5c2e79c96628383d8dca4cdc5317d (patch)
tree3b9fff192f433d535e88b016d76e19fd1e417b74
parentd2189933e8dfa936efd4ee3044206f150339efec (diff)
parent763ae5cb68303595c1bb1fb0133a03d52634a9ac (diff)
Merge pull request #4399 from Gurthurb/master
Avoid NullReferenceException if an IAsyncResult or WebRequest doesn't contain a WebResponse property
-rw-r--r--Duplicati/Library/Utility/AsyncHttpRequest.cs4
1 files changed, 2 insertions, 2 deletions
diff --git a/Duplicati/Library/Utility/AsyncHttpRequest.cs b/Duplicati/Library/Utility/AsyncHttpRequest.cs
index 7a276230a..0ba349d71 100644
--- a/Duplicati/Library/Utility/AsyncHttpRequest.cs
+++ b/Duplicati/Library/Utility/AsyncHttpRequest.cs
@@ -230,11 +230,11 @@ namespace Duplicati.Library.Utility
{
WebResponse resp = null;
- try { resp = (WebResponse)r.GetType().GetProperty("Response", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(r); }
+ try { resp = r.GetType().GetProperty("Response", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)?.GetValue(r) as WebResponse; }
catch {}
if (resp == null)
- try { resp = (WebResponse)m_owner.m_request.GetType().GetField("webResponse", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(m_owner.m_request); }
+ try { resp = m_owner.m_request.GetType().GetField("webResponse", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)?.GetValue(m_owner.m_request) as WebResponse; }
catch { }
if (resp != null)