From 71edf641a5c94eaa2ca2ca09dcf5a9283f3df8bd Mon Sep 17 00:00:00 2001 From: Kenneth Hsu Date: Sun, 27 Sep 2020 09:36:03 -0700 Subject: [PATCH] Avoid null reference exception when building Sia error messages. If the resource does not provide an error response, the Response property will be null. This fixes #4193. --- Duplicati/Library/Backend/Sia/Sia.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Duplicati/Library/Backend/Sia/Sia.cs b/Duplicati/Library/Backend/Sia/Sia.cs index 97aed2e7f..62db58a37 100644 --- a/Duplicati/Library/Backend/Sia/Sia.cs +++ b/Duplicati/Library/Backend/Sia/Sia.cs @@ -83,6 +83,11 @@ namespace Duplicati.Library.Backend.Sia private string getResponseBodyOnError(string context, System.Net.WebException wex) { + if (wex.Response is null) + { + return $"{context} failed with error: {wex.Message}"; + } + string body = ""; System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)wex.Response; using (System.IO.Stream data = response.GetResponseStream())