(reviewboard seems to be down today, so sending this the old-fashioned way)

Hi,

Stumbled upon a bad_alloc exception in Plasma today: after some
debugging I found out that sometimes
FrameSvgPrivate::generateFrameBackground() tried to generate a
background of size 16777215 x 13. 16777215 is QWIDGETSIZE_MAX.

It seems the buggy size comes from the way the System Monitor applet
uses Plasma::Frame, but I thought adding a generic guard in
generateFrameBackground() would be useful, hence the attached patch.

Actually I am thinking it may make sense to set stricter limits, for
example ensuring each dimension is less than say 10000 pixels.

What do you think about this?

Aurélien
diff --git a/plasma/framesvg.cpp b/plasma/framesvg.cpp
index 981e8fa..611acc0 100644
--- a/plasma/framesvg.cpp
+++ b/plasma/framesvg.cpp
@@ -27,6 +27,7 @@
 #include <QRegion>
 #include <QTimer>
 #include <QCryptographicHash>
+#include <QWidget>
 
 #include <kdebug.h>
 
@@ -490,6 +491,10 @@ void FrameSvgPrivate::generateFrameBackground(FrameData *frame)
         kWarning() << "Invalid frame size" << size;
         return;
     }
+    if (size.width() == QWIDGETSIZE_MAX || size.height() == QWIDGETSIZE_MAX) {
+        kWarning() << "Not generating frame background for a size whose width or height is QWIDGETSIZE_MAX" << size;
+        return;
+    }
 
     const int contentWidth = size.width() - frame->leftWidth  - frame->rightWidth;
     const int contentHeight = size.height() - frame->topHeight  - frame->bottomHeight;
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to