summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-07-28 16:29:43 +0200
committerAndrzej Hunt <andrzej.hunt@collabora.com>2014-07-28 16:34:18 +0200
commitc1d9fe079a32a0515683236f91892c98ee837f8b (patch)
treefd46fa86135ac561403e80cbe812193d129a2821
parent03fe3215e35d07319eac4a0e7a8d6e5563244492 (diff)
Prevent LOK DocView crash if document too large.
There seems to be a maximum size that gdk's pixbuf can handle, however I have been unable to find any documentatation. Seeing as the current implementation isn't realistically useable anyway, we might as well set a hard limit here (in practice we'd have much smaller tiles + compositing). Specifically extras/source/shellnew/soffice.ods will fail without this patch. Change-Id: I6ac495adca8e15878989375ef8b2de472788279a
-rw-r--r--libreofficekit/source/gtk/lokdocview.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/libreofficekit/source/gtk/lokdocview.c b/libreofficekit/source/gtk/lokdocview.c
index cdc23392f646..e8fe5264a418 100644
--- a/libreofficekit/source/gtk/lokdocview.c
+++ b/libreofficekit/source/gtk/lokdocview.c
@@ -108,12 +108,26 @@ void renderDocument( LOKDocView* pDocView )
pDocView->pDocument->pClass->getDocumentSize( pDocView->pDocument, &nWidth, &nHeight );
- // Draw the whole document at once (for now)
-
// TODO: we really should scale by screen DPI here -- 10 seems to be a vaguely
// correct factor for my screen at least.
- nRenderWidth = nWidth * pDocView->fZoom / 10;
- nRenderHeight = nHeight * pDocView->fZoom / 10;
+ const float fScaleFactor = 0.1;
+
+ // Various things blow up if we try to draw too large a tile,
+ // this size seems to be safe. (Very rare/unlikely that
+ const int nMaxWidth = 100000;
+ if ( nWidth * fScaleFactor > nMaxWidth )
+ {
+ nWidth = nMaxWidth;
+ }
+ if ( nHeight * fScaleFactor > nMaxWidth )
+ {
+ nHeight = nMaxWidth;
+ }
+
+ // Draw the whole document at once (for now)
+
+ nRenderWidth = nWidth * pDocView->fZoom * fScaleFactor;
+ nRenderHeight = nHeight * pDocView->fZoom * fScaleFactor;
pDocView->pPixBuf = gdk_pixbuf_new( GDK_COLORSPACE_RGB,
TRUE, 8,