diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-08-30 13:42:43 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2016-08-30 12:02:09 +0000 |
commit | 579283507c392fc5bc0976c054304ecb8938cb06 (patch) | |
tree | 4da46bf12275a0c318f4cbdfa92830a5669d96f5 /src/printsupport | |
parent | ce2815b43c3f10c474c35d30197e14c58c9106ff (diff) | |
download | qtbase-579283507c392fc5bc0976c054304ecb8938cb06.tar.gz |
QWin32PrintEngine: Fix uninitialized memory read of dpi_x, dpi_y
Discovered by purify:
QWin32PrintEnginePrivate::initialize() called updateMetrics()
via updatePageLayout() after initHDC(), so dpi_x, dpi_y
were accessed before initialized from the display resolution.
Fix by moving the call initHDC() up and giving default
values.
Change-Id: Ia360c06d156e569ca6b1472ec5b5cdc52948f913
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Diffstat (limited to 'src/printsupport')
-rw-r--r-- | src/printsupport/kernel/qprintengine_win.cpp | 4 | ||||
-rw-r--r-- | src/printsupport/kernel/qprintengine_win_p.h | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/printsupport/kernel/qprintengine_win.cpp b/src/printsupport/kernel/qprintengine_win.cpp index a9d316095c..1c02d389fe 100644 --- a/src/printsupport/kernel/qprintengine_win.cpp +++ b/src/printsupport/kernel/qprintengine_win.cpp @@ -918,14 +918,14 @@ void QWin32PrintEnginePrivate::initialize() Q_ASSERT(hPrinter); Q_ASSERT(pInfo); + initHDC(); + if (devMode) { num_copies = devMode->dmCopies; devMode->dmCollate = DMCOLLATE_TRUE; updatePageLayout(); } - initHDC(); - #if defined QT_DEBUG_DRAW || defined QT_DEBUG_METRICS qDebug() << "QWin32PrintEngine::initialize()"; debugMetrics(); diff --git a/src/printsupport/kernel/qprintengine_win_p.h b/src/printsupport/kernel/qprintengine_win_p.h index c1d7b452f9..74b78ae2b1 100644 --- a/src/printsupport/kernel/qprintengine_win_p.h +++ b/src/printsupport/kernel/qprintengine_win_p.h @@ -124,10 +124,14 @@ public: state(QPrinter::Idle), resolution(0), m_pageLayout(QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF(0, 0, 0, 0))), + stretch_x(1), stretch_y(1), origin_x(0), origin_y(0), + dpi_x(96), dpi_y(96), dpi_display(96), num_copies(1), printToFile(false), reinit(false), - embed_fonts(true) + complex_xform(false), has_pen(false), has_brush(false), has_custom_paper_size(false), + embed_fonts(true), + txop(0 /* QTransform::TxNone */) { } |