ca9047
diff --git a/src/dec/buffer_dec.c b/src/dec/buffer_dec.c
ca9047
index 75eb3c4..3cd94eb 100644
ca9047
--- a/src/dec/buffer_dec.c
ca9047
+++ b/src/dec/buffer_dec.c
ca9047
@@ -74,7 +74,8 @@
ca9047
   } else {    // RGB checks
ca9047
     const WebPRGBABuffer* const buf = &buffer->u.RGBA;
ca9047
     const int stride = abs(buf->stride);
ca9047
-    const uint64_t size = MIN_BUFFER_SIZE(width, height, stride);
ca9047
+    const uint64_t size =
ca9047
+        MIN_BUFFER_SIZE(width * kModeBpp[mode], height, stride);
ca9047
     ok &= (size <= buf->size);
ca9047
     ok &= (stride >= width * kModeBpp[mode]);
ca9047
     ok &= (buf->rgba != NULL);
ca9047