[poppler] qt5/demos

Albert Astals Cid aacid at kemper.freedesktop.org
Tue Dec 26 22:57:40 UTC 2017


 qt5/demos/pageview.cpp |    7 +++++++
 1 file changed, 7 insertions(+)

New commits:
commit ffefe1c038de555ed39c3d9eca6ef79ac1f97b86
Author: Albert Astals Cid <aacid at kde.org>
Date:   Tue Dec 26 23:57:21 2017 +0100

    qt5: demo: don't crash if page is malformed

diff --git a/qt5/demos/pageview.cpp b/qt5/demos/pageview.cpp
index 4f56108e..81e6a98f 100644
--- a/qt5/demos/pageview.cpp
+++ b/qt5/demos/pageview.cpp
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2008-2009, Pino Toscano <pino at kde.org>
  * Copyright (C) 2013, Fabio D'Urso <fabiodurso at hotmail.it>
+ * Copyright (C) 2017, Albert Astals Cid <aacid at kde.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -26,6 +27,7 @@
 #include <QtGui/QImage>
 #include <QtWidgets/QLabel>
 #include <QtGui/QPixmap>
+#include <QDebug>
 
 PageView::PageView(QWidget *parent)
     : QScrollArea(parent)
@@ -56,6 +58,11 @@ void PageView::documentClosed()
 void PageView::pageChanged(int page)
 {
     Poppler::Page *popplerPage = document()->page(page);
+
+    if (!popplerPage) {
+        qDebug() << "Page" << page << "is malformed";
+        return;
+    }
     const double resX = m_dpiX * m_zoom;
     const double resY = m_dpiY * m_zoom;
 


More information about the poppler mailing list