Skip to content

Commit 24cfb74

Browse files
committed
Surround base64 decoding with try/catch
1 parent 079235b commit 24cfb74

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

Runtime/CesiumCreditSystem.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,17 @@ internal IEnumerator LoadImage(string url)
296296
// Load an image from a string that contains the
297297
// "data:image/png;base64," prefix
298298
string byteString = url.Substring(base64Prefix.Length);
299-
byte[] bytes = Convert.FromBase64String(byteString);
300-
if (!texture.LoadImage(bytes))
299+
try
301300
{
302-
Debug.Log("Could not parse image from base64 string.");
301+
byte[] bytes = Convert.FromBase64String(byteString);
302+
if (!texture.LoadImage(bytes))
303+
{
304+
Debug.Log("Credit image could not be loaded into Texture2D.");
305+
}
306+
}
307+
catch (FormatException e)
308+
{
309+
Debug.Log("Could not parse credit image from base64 string.");
303310
}
304311
}
305312
else
@@ -311,7 +318,7 @@ internal IEnumerator LoadImage(string url)
311318
if (request.result == UnityWebRequest.Result.ConnectionError ||
312319
request.result == UnityWebRequest.Result.ProtocolError)
313320
{
314-
Debug.Log(request.error);
321+
Debug.LogError(request.error);
315322
}
316323
else
317324
{

0 commit comments

Comments
 (0)