Skip to content
This repository
Browse code

Guard against failed memory allocation in CGUIDialogVideoBookmarks::A…

…ddBookmark()
  • Loading branch information...
commit 598cda322df04c2b0dcdb94c4e66575595a46cf8 1 parent bdef87b
Garrett Brown authored March 26, 2013
31  xbmc/video/dialogs/GUIDialogVideoBookmarks.cpp
@@ -264,21 +264,26 @@ void CGUIDialogVideoBookmarks::AddBookmark(CVideoInfoTag* tag)
264 264
   {
265 265
 #ifdef HAS_VIDEO_PLAYBACK
266 266
     CRenderCapture* thumbnail = g_renderManager.AllocRenderCapture();
267  
-    g_renderManager.Capture(thumbnail, width, height, CAPTUREFLAG_IMMEDIATELY);
268  
-    if (thumbnail->GetUserState() == CAPTURESTATE_DONE)
  267
+
  268
+    if (thumbnail)
269 269
     {
270  
-      Crc32 crc;
271  
-      crc.ComputeFromLowerCase(g_application.CurrentFile());
272  
-      bookmark.thumbNailImage.Format("%08x_%i.jpg", (unsigned __int32) crc, m_vecItems->Size() + 1);
273  
-      bookmark.thumbNailImage = URIUtils::AddFileToFolder(g_settings.GetBookmarksThumbFolder(), bookmark.thumbNailImage);
274  
-      if (!CPicture::CreateThumbnailFromSurface(thumbnail->GetPixels(), width, height, thumbnail->GetWidth() * 4,
275  
-                                          bookmark.thumbNailImage))
276  
-        bookmark.thumbNailImage.Empty();
277  
-    }
278  
-    else
279  
-      CLog::Log(LOGERROR,"CGUIDialogVideoBookmarks: failed to create thumbnail");
  270
+      g_renderManager.Capture(thumbnail, width, height, CAPTUREFLAG_IMMEDIATELY);
280 271
 
281  
-    g_renderManager.ReleaseRenderCapture(thumbnail);
  272
+      if (thumbnail->GetUserState() == CAPTURESTATE_DONE)
  273
+      {
  274
+        Crc32 crc;
  275
+        crc.ComputeFromLowerCase(g_application.CurrentFile());
  276
+        bookmark.thumbNailImage.Format("%08x_%i.jpg", (unsigned __int32) crc, m_vecItems->Size() + 1);
  277
+        bookmark.thumbNailImage = URIUtils::AddFileToFolder(g_settings.GetBookmarksThumbFolder(), bookmark.thumbNailImage);
  278
+        if (!CPicture::CreateThumbnailFromSurface(thumbnail->GetPixels(), width, height, thumbnail->GetWidth() * 4,
  279
+                                            bookmark.thumbNailImage))
  280
+          bookmark.thumbNailImage.Empty();
  281
+      }
  282
+      else
  283
+        CLog::Log(LOGERROR,"CGUIDialogVideoBookmarks: failed to create thumbnail");
  284
+
  285
+      g_renderManager.ReleaseRenderCapture(thumbnail);
  286
+    }
282 287
 #endif
283 288
   }
284 289
   videoDatabase.Open();

0 notes on commit 598cda3

Please sign in to comment.
Something went wrong with that request. Please try again.