[vlc-commits] Skins2: add check on bitmaps to avoid crash
Erwan Tulou
git at videolan.org
Wed Jun 17 14:45:57 CEST 2015
vlc/vlc-2.2 | branch: master | Erwan Tulou <erwan10 at videolan.org> | Wed Jun 17 12:46:48 2015 +0200| [f59e289efdef3086571e20d3cd281fed3bda0bca] | committer: Erwan Tulou
Skins2: add check on bitmaps to avoid crash
(cherry picked from commit d7b946844c7aeb97c878779f8ea0cba548626504)
Signed-off-by: Erwan Tulou <erwan10 at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=f59e289efdef3086571e20d3cd281fed3bda0bca
---
modules/gui/skins2/parser/builder.cpp | 49 ++++++++++++++++++---------------
1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/modules/gui/skins2/parser/builder.cpp b/modules/gui/skins2/parser/builder.cpp
index 5b7d1a7..bf470b5 100644
--- a/modules/gui/skins2/parser/builder.cpp
+++ b/modules/gui/skins2/parser/builder.cpp
@@ -132,7 +132,7 @@ Theme *Builder::build()
// Macro to get a bitmap by its ID in the builder
-#define GET_BMP( pBmp, id ) \
+#define GET_BMP( pBmp, id, abort ) \
if( id != "none" ) \
{ \
pBmp = m_pTheme->getBitmapById(id); \
@@ -141,6 +141,11 @@ Theme *Builder::build()
msg_Err( getIntf(), "unknown bitmap id: %s", id.c_str() ); \
return; \
} \
+ } \
+ else if( abort )\
+ { \
+ msg_Err( getIntf(), "bitmap required for id: %s", rData.m_id.c_str() ); \
+ return; \
}
// macro to check bitmap size consistency for button and checkbox
@@ -244,7 +249,7 @@ void Builder::addSubBitmap( const BuilderData::SubBitmap &rData )
// Get the parent bitmap
GenericBitmap *pParentBmp = NULL;
- GET_BMP( pParentBmp, rData.m_parent );
+ GET_BMP( pParentBmp, rData.m_parent, true );
// Copy a region of the parent bitmap to the new one
BitmapImpl *pBmp =
@@ -457,13 +462,13 @@ void Builder::addButton( const BuilderData::Button &rData )
{
// Get the bitmaps of the button
GenericBitmap *pBmpUp = NULL;
- GET_BMP( pBmpUp, rData.m_upId );
+ GET_BMP( pBmpUp, rData.m_upId, true );
GenericBitmap *pBmpDown = pBmpUp;
- GET_BMP( pBmpDown, rData.m_downId );
+ GET_BMP( pBmpDown, rData.m_downId, false );
GenericBitmap *pBmpOver = pBmpUp;
- GET_BMP( pBmpOver, rData.m_overId );
+ GET_BMP( pBmpOver, rData.m_overId, false );
GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
if( pLayout == NULL )
@@ -519,22 +524,22 @@ void Builder::addCheckbox( const BuilderData::Checkbox &rData )
{
// Get the bitmaps of the checkbox
GenericBitmap *pBmpUp1 = NULL;
- GET_BMP( pBmpUp1, rData.m_up1Id );
+ GET_BMP( pBmpUp1, rData.m_up1Id, true );
GenericBitmap *pBmpDown1 = pBmpUp1;
- GET_BMP( pBmpDown1, rData.m_down1Id );
+ GET_BMP( pBmpDown1, rData.m_down1Id, false );
GenericBitmap *pBmpOver1 = pBmpUp1;
- GET_BMP( pBmpOver1, rData.m_over1Id );
+ GET_BMP( pBmpOver1, rData.m_over1Id, false );
GenericBitmap *pBmpUp2 = NULL;
- GET_BMP( pBmpUp2, rData.m_up2Id );
+ GET_BMP( pBmpUp2, rData.m_up2Id, true );
GenericBitmap *pBmpDown2 = pBmpUp2;
- GET_BMP( pBmpDown2, rData.m_down2Id );
+ GET_BMP( pBmpDown2, rData.m_down2Id, false );
GenericBitmap *pBmpOver2 = pBmpUp2;
- GET_BMP( pBmpOver2, rData.m_over2Id );
+ GET_BMP( pBmpOver2, rData.m_over2Id, false );
GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
if( pLayout == NULL )
@@ -611,7 +616,7 @@ void Builder::addCheckbox( const BuilderData::Checkbox &rData )
void Builder::addImage( const BuilderData::Image &rData )
{
GenericBitmap *pBmp = NULL;
- GET_BMP( pBmp, rData.m_bmpId );
+ GET_BMP( pBmp, rData.m_bmpId, true );
GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
if( pLayout == NULL )
@@ -810,7 +815,7 @@ void Builder::addRadialSlider( const BuilderData::RadialSlider &rData )
{
// Get the bitmaps of the slider
GenericBitmap *pSeq = NULL;
- GET_BMP( pSeq, rData.m_sequence );
+ GET_BMP( pSeq, rData.m_sequence, true );
GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
if( pLayout == NULL )
@@ -864,7 +869,7 @@ void Builder::addSlider( const BuilderData::Slider &rData )
// Get the bitmaps of the background
GenericBitmap *pBgImage = NULL;
- GET_BMP( pBgImage, rData.m_imageId );
+ GET_BMP( pBgImage, rData.m_imageId, false );
GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
if( pLayout == NULL )
@@ -916,13 +921,13 @@ void Builder::addSlider( const BuilderData::Slider &rData )
// Get the bitmaps of the cursor
GenericBitmap *pBmpUp = NULL;
- GET_BMP( pBmpUp, rData.m_upId );
+ GET_BMP( pBmpUp, rData.m_upId, true );
GenericBitmap *pBmpDown = pBmpUp;
- GET_BMP( pBmpDown, rData.m_downId );
+ GET_BMP( pBmpDown, rData.m_downId, false );
GenericBitmap *pBmpOver = pBmpUp;
- GET_BMP( pBmpOver, rData.m_overId );
+ GET_BMP( pBmpOver, rData.m_overId, false );
// Create the cursor control
CtrlSliderCursor *pCursor = new CtrlSliderCursor( getIntf(), *pBmpUp,
@@ -942,7 +947,7 @@ void Builder::addList( const BuilderData::List &rData )
{
// Get the background bitmap, if any
GenericBitmap *pBgBmp = NULL;
- GET_BMP( pBgBmp, rData.m_bgImageId );
+ GET_BMP( pBgBmp, rData.m_bgImageId, false );
GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
if( pLayout == NULL )
@@ -1003,10 +1008,10 @@ void Builder::addTree( const BuilderData::Tree &rData )
GenericBitmap *pItemBmp = NULL;
GenericBitmap *pOpenBmp = NULL;
GenericBitmap *pClosedBmp = NULL;
- GET_BMP( pBgBmp, rData.m_bgImageId );
- GET_BMP( pItemBmp, rData.m_itemImageId );
- GET_BMP( pOpenBmp, rData.m_openImageId );
- GET_BMP( pClosedBmp, rData.m_closedImageId );
+ GET_BMP( pBgBmp, rData.m_bgImageId, false );
+ GET_BMP( pItemBmp, rData.m_itemImageId, false );
+ GET_BMP( pOpenBmp, rData.m_openImageId, false );
+ GET_BMP( pClosedBmp, rData.m_closedImageId, false );
GenericLayout *pLayout = m_pTheme->getLayoutById( rData.m_layoutId );
if( pLayout == NULL )
More information about the vlc-commits
mailing list