Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Guard against failed memory allocation in CGUIDialogVideoBookmarks::A…

…ddBookmark()
  • Loading branch information...
commit 598cda322df04c2b0dcdb94c4e66575595a46cf8 1 parent bdef87b
@garbear garbear authored
Showing with 18 additions and 13 deletions.
  1. +18 −13 xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp
View
31 xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp
@@ -264,21 +264,26 @@ void CGUIDialogVideoBookmarks::AddBookmark(CVideoInfoTag* tag)
{
#ifdef HAS_VIDEO_PLAYBACK
CRenderCapture* thumbnail = g_renderManager.AllocRenderCapture();
- g_renderManager.Capture(thumbnail, width, height, CAPTUREFLAG_IMMEDIATELY);
- if (thumbnail->GetUserState() == CAPTURESTATE_DONE)
+
+ if (thumbnail)
{
- Crc32 crc;
- crc.ComputeFromLowerCase(g_application.CurrentFile());
- bookmark.thumbNailImage.Format("%08x_%i.jpg", (unsigned __int32) crc, m_vecItems->Size() + 1);
- bookmark.thumbNailImage = URIUtils::AddFileToFolder(g_settings.GetBookmarksThumbFolder(), bookmark.thumbNailImage);
- if (!CPicture::CreateThumbnailFromSurface(thumbnail->GetPixels(), width, height, thumbnail->GetWidth() * 4,
- bookmark.thumbNailImage))
- bookmark.thumbNailImage.Empty();
- }
- else
- CLog::Log(LOGERROR,"CGUIDialogVideoBookmarks: failed to create thumbnail");
+ g_renderManager.Capture(thumbnail, width, height, CAPTUREFLAG_IMMEDIATELY);
- g_renderManager.ReleaseRenderCapture(thumbnail);
+ if (thumbnail->GetUserState() == CAPTURESTATE_DONE)
+ {
+ Crc32 crc;
+ crc.ComputeFromLowerCase(g_application.CurrentFile());
+ bookmark.thumbNailImage.Format("%08x_%i.jpg", (unsigned __int32) crc, m_vecItems->Size() + 1);
+ bookmark.thumbNailImage = URIUtils::AddFileToFolder(g_settings.GetBookmarksThumbFolder(), bookmark.thumbNailImage);
+ if (!CPicture::CreateThumbnailFromSurface(thumbnail->GetPixels(), width, height, thumbnail->GetWidth() * 4,
+ bookmark.thumbNailImage))
+ bookmark.thumbNailImage.Empty();
+ }
+ else
+ CLog::Log(LOGERROR,"CGUIDialogVideoBookmarks: failed to create thumbnail");
+
+ g_renderManager.ReleaseRenderCapture(thumbnail);
+ }
#endif
}
videoDatabase.Open();
Please sign in to comment.
Something went wrong with that request. Please try again.