diff --git a/modules/gui/skins2/src/file_bitmap.cpp b/modules/gui/skins2/src/file_bitmap.cpp
index 658bdc122f536c009c364c6e94e30f385c624981..c9505be370f750840130402148e89059fea9ca00 100644
--- a/modules/gui/skins2/src/file_bitmap.cpp
+++ b/modules/gui/skins2/src/file_bitmap.cpp
@@ -38,6 +38,7 @@ FileBitmap::FileBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler,
 {
     video_format_t fmt_out;
     picture_t *pPic;
+    unsigned size;
 
     video_format_Init( &fmt_out, VLC_CODEC_RGBA );
 
@@ -61,7 +62,11 @@ FileBitmap::FileBitmap( intf_thread_t *pIntf, image_handler_t *pImageHandler,
     m_height = fmt_out.i_height;
     video_format_Clean( &fmt_out );
 
-    m_pData = new uint8_t[m_height * m_width * 4];
+    if (mul_overflow((unsigned)m_width, (unsigned)m_height, &size)
+     || mul_overflow(size, 4, &size))
+        throw std::bad_alloc();
+
+    m_pData = new uint8_t[size];
 
     // Compute the alpha layer
     uint8_t *pData = m_pData, *pSrc = pPic->p->p_pixels;
diff --git a/modules/gui/skins2/src/ft2_bitmap.cpp b/modules/gui/skins2/src/ft2_bitmap.cpp
index 08ce4a3421bcf1c0748497cb7c4c5ad72f0b5efc..7b1c4687058940a2d3784b37dd3ea1b42d5c7c3f 100644
--- a/modules/gui/skins2/src/ft2_bitmap.cpp
+++ b/modules/gui/skins2/src/ft2_bitmap.cpp
@@ -27,9 +27,15 @@
 FT2Bitmap::FT2Bitmap( intf_thread_t *pIntf, int width, int height ):
     GenericBitmap( pIntf ), m_width( width ), m_height( height )
 {
+    unsigned size;
+
+    if (mul_overflow((unsigned)width, (unsigned)height, &size)
+     || mul_overflow(size, 4, &size))
+        throw std::bad_alloc();
+
     // Allocate memory for the buffer
-    m_pData = new uint8_t[m_height * m_width * 4];
-    memset( m_pData, 0, m_height * m_width * 4 );
+    m_pData = new uint8_t[size];
+    memset(m_pData, 0, size);
 }
 
 
diff --git a/modules/gui/skins2/src/generic_bitmap.cpp b/modules/gui/skins2/src/generic_bitmap.cpp
index 60edecca40ee86624f208e84a32a3d5253d683ae..a0c40f404ac726ffd961e9ac435b4f92f85e7bec 100644
--- a/modules/gui/skins2/src/generic_bitmap.cpp
+++ b/modules/gui/skins2/src/generic_bitmap.cpp
@@ -57,8 +57,14 @@ BitmapImpl::BitmapImpl( intf_thread_t *pIntf, int width, int height,
     GenericBitmap( pIntf, nbFrames, fps, nbLoops ), m_width( width ),
     m_height( height ), m_pData( NULL )
 {
-    m_pData = new uint8_t[width * height * 4];
-    memset( m_pData, 0, width * height * 4 );
+    unsigned size;
+
+    if (mul_overflow((unsigned)width, (unsigned)height, &size)
+     || mul_overflow(size, 4, &size))
+        throw std::bad_alloc();
+
+    m_pData = new uint8_t[size];
+    memset(m_pData, 0, size);
 }
 
 
diff --git a/modules/gui/skins2/src/scaled_bitmap.cpp b/modules/gui/skins2/src/scaled_bitmap.cpp
index a85877b381fab34e5064116d99a86a229185c29c..0bcbd02c4cd9e6dafb5c12b43b55f81f89f9f988 100644
--- a/modules/gui/skins2/src/scaled_bitmap.cpp
+++ b/modules/gui/skins2/src/scaled_bitmap.cpp
@@ -28,10 +28,14 @@ ScaledBitmap::ScaledBitmap( intf_thread_t *pIntf, const GenericBitmap &rBitmap,
                             int width, int height ):
     GenericBitmap( pIntf ), m_width( width ), m_height( height )
 {
-    // XXX We should check that width and height are positive...
+    unsigned size;
+
+    if (mul_overflow((unsigned)width, (unsigned)height, &size)
+     || mul_overflow(size, 4, &size))
+        throw std::bad_alloc();
 
     // Allocate memory for the buffer
-    m_pData = new uint8_t[m_height * m_width * 4];
+    m_pData = new uint8_t[size];
 
     int srcWidth = rBitmap.getWidth();
     int srcHeight = rBitmap.getHeight();