From 7bd9aa191c97f169ca753d18c335310a5d17d790 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Fri, 22 Mar 2024 17:31:37 +0100 Subject: [PATCH] QPdf: assert that we can load the files from the resources These are files under our control, but still, may get moved/renamed/... by accident. Assert that we can open them. Change-Id: I46987f2f12e04a8d7292652eb6440fa0f345175a Reviewed-by: Lars Knoll --- src/gui/painting/qpdf.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 85d3874f94..bf653cb3f4 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1772,7 +1772,8 @@ int QPdfEnginePrivate::writeXmpDcumentMetaData() const QString metaDataDate = timeStr + tzStr; QFile metaDataFile(":/qpdf/qpdfa_metadata.xml"_L1); - metaDataFile.open(QIODevice::ReadOnly); + bool ok = metaDataFile.open(QIODevice::ReadOnly); + Q_ASSERT(ok); metaDataContent = QString::fromUtf8(metaDataFile.readAll()).arg(producer.toHtmlEscaped(), title.toHtmlEscaped(), creator.toHtmlEscaped(), @@ -1798,7 +1799,8 @@ int QPdfEnginePrivate::writeOutputIntent() const int colorProfile = addXrefEntry(-1); { QFile colorProfileFile(":/qpdf/sRGB2014.icc"_L1); - colorProfileFile.open(QIODevice::ReadOnly); + bool ok = colorProfileFile.open(QIODevice::ReadOnly); + Q_ASSERT(ok); const QByteArray colorProfileData = colorProfileFile.readAll(); QByteArray data;