From 6ffab6cc65eeafe8466b2b1728be89cf8e0f88dc Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Sun, 12 Feb 2012 00:36:26 +0100 Subject: Ensure renderWidth is no more than 2000. I saw some sites with strange CMS and with absurd content size width (eg: my school's site has 8584553) This usually leads setViewportSize to crash :( --- src/websnap.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/websnap.cpp') diff --git a/src/websnap.cpp b/src/websnap.cpp index f077db84..830d37e1 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -102,7 +102,12 @@ QPixmap WebSnap::renderPagePreview(const QWebPage &page, int w, int h) QSize oldSize = page.viewportSize(); // prepare page + // NOTE: I saw some sites with strange CMS and with absurd content size width (eg: 8584553) + // This usually leads setViewportSize to crash :( + // So, ensure renderWidth is no more than 2000. int renderWidth = page.mainFrame()->contentsSize().width(); + if (renderWidth > 2000) + renderWidth = 2000; int renderHeight = renderWidth * ((0.0 + h) / w); page.setViewportSize(QSize(renderWidth, renderHeight)); -- cgit v1.2.1