From 13f347a81343942458e8a8565c20241d1a25cc17 Mon Sep 17 00:00:00 2001 From: crobibero Date: Tue, 5 Jan 2021 07:00:48 -0700 Subject: [PATCH] Fix potential null reference --- Emby.Server.Implementations/Dto/DtoService.cs | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index d5e1f5124..8a901516c 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -582,16 +582,22 @@ namespace Emby.Server.Implementations.Dto { baseItemPerson.PrimaryImageTag = GetTagAndFillBlurhash(dto, entity, ImageType.Primary); baseItemPerson.Id = entity.Id.ToString("N", CultureInfo.InvariantCulture); - // Only add BlurHash for the person's image. - baseItemPerson.ImageBlurHashes = new Dictionary>(); - foreach (var (imageType, blurHash) in dto.ImageBlurHashes) + if (dto.ImageBlurHashes != null) { - baseItemPerson.ImageBlurHashes[imageType] = new Dictionary(); - foreach (var (imageId, blurHashValue) in blurHash) + // Only add BlurHash for the person's image. + baseItemPerson.ImageBlurHashes = new Dictionary>(); + foreach (var (imageType, blurHash) in dto.ImageBlurHashes) { - if (string.Equals(baseItemPerson.PrimaryImageTag, imageId, StringComparison.OrdinalIgnoreCase)) + if (blurHash != null) { - baseItemPerson.ImageBlurHashes[imageType][imageId] = blurHashValue; + baseItemPerson.ImageBlurHashes[imageType] = new Dictionary(); + foreach (var (imageId, blurHashValue) in blurHash) + { + if (string.Equals(baseItemPerson.PrimaryImageTag, imageId, StringComparison.OrdinalIgnoreCase)) + { + baseItemPerson.ImageBlurHashes[imageType][imageId] = blurHashValue; + } + } } } }