From a1a6366833cbf3624c5a84c7a2a4d74b635d5aef Mon Sep 17 00:00:00 2001 From: Mike Date: Wed, 25 Mar 2015 21:30:26 -0400 Subject: [PATCH] Fix null reference exception when awaiting null. DynamicImageProvider:CreateImageAsync was not marked as async. When returning null the await BaseDynamicImageProvider:FetchToFileInternal would throw a null reference exception. An alternative solution would be to wrap the null return in Task.FromResult. Object reference not set to an instance of an object. System.NullReferenceException at MediaBrowser.Server.Implementations.Photos.BaseDynamicImageProvider`1.d__c.MoveNext() in c:\MediaBrowser\MediaBrowser.Server.Implementations\Photos\BaseDynamicImageProvider.cs:line 79 --- .../UserViews/DynamicImageProvider.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs b/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs index b98dd2c49..d6a94210c 100644 --- a/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs +++ b/MediaBrowser.Server.Implementations/UserViews/DynamicImageProvider.cs @@ -238,7 +238,7 @@ namespace MediaBrowser.Server.Implementations.UserViews return collectionStripViewTypes.Contains(view.ViewType ?? string.Empty); } - protected override Task CreateImageAsync(IHasImages item, List itemsWithImages, ImageType imageType, int imageIndex) + protected override async Task CreateImageAsync(IHasImages item, List itemsWithImages, ImageType imageType, int imageIndex) { var view = (UserView)item; if (imageType == ImageType.Primary && IsUsingCollectionStrip(view)) @@ -249,10 +249,10 @@ namespace MediaBrowser.Server.Implementations.UserViews } var stream = new StripCollageBuilder(ApplicationPaths).BuildThumbCollage(GetStripCollageImagePaths(itemsWithImages, view.ViewType), item.Name, 960, 540); - return Task.FromResult(stream); + return stream; } - return base.CreateImageAsync(item, itemsWithImages, imageType, imageIndex); + return await base.CreateImageAsync(item, itemsWithImages, imageType, imageIndex); } private IEnumerable GetStripCollageImagePaths(IEnumerable items, string viewType)