From 3b1e8f705422200357a00cd402a34da55b86a79e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= Date: Sat, 19 Nov 2022 11:38:49 +0000 Subject: [PATCH] minor tweaks in HEIF and AVIF plugins It is mostly only about casting between types. --- src/imageformats/avif.cpp | 4 ++-- src/imageformats/heif.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/imageformats/avif.cpp b/src/imageformats/avif.cpp index 256f458..0f1319b 100644 --- a/src/imageformats/avif.cpp +++ b/src/imageformats/avif.cpp @@ -63,7 +63,7 @@ bool QAVIFHandler::canRead(QIODevice *device) } avifROData input; - input.data = (const uint8_t *)header.constData(); + input.data = reinterpret_cast(header.constData()); input.size = header.size(); if (avifPeekCompatibleFileType(&input)) { @@ -116,7 +116,7 @@ bool QAVIFHandler::ensureDecoder() m_rawData = device()->readAll(); - m_rawAvifData.data = (const uint8_t *)m_rawData.constData(); + m_rawAvifData.data = reinterpret_cast(m_rawData.constData()); m_rawAvifData.size = m_rawData.size(); if (avifPeekCompatibleFileType(&m_rawAvifData) == AVIF_FALSE) { diff --git a/src/imageformats/heif.cpp b/src/imageformats/heif.cpp index ba5d2ce..b876e59 100644 --- a/src/imageformats/heif.cpp +++ b/src/imageformats/heif.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include namespace // Private. @@ -637,8 +638,8 @@ bool HEIFHandler::ensureDecoder() heif_color_profile_type profileType = heif_image_handle_get_color_profile_type(handle.get_raw_image_handle()); struct heif_error err; if (profileType == heif_color_profile_type_prof || profileType == heif_color_profile_type_rICC) { - int rawProfileSize = (int)heif_image_handle_get_raw_color_profile_size(handle.get_raw_image_handle()); - if (rawProfileSize > 0) { + size_t rawProfileSize = heif_image_handle_get_raw_color_profile_size(handle.get_raw_image_handle()); + if (rawProfileSize > 0 && rawProfileSize < std::numeric_limits::max()) { QByteArray ba(rawProfileSize, 0); err = heif_image_handle_get_raw_color_profile(handle.get_raw_image_handle(), ba.data()); if (err.code) { @@ -650,7 +651,7 @@ bool HEIFHandler::ensureDecoder() } } } else { - qWarning() << "icc profile is empty"; + qWarning() << "icc profile is empty or above limits"; } } else if (profileType == heif_color_profile_type_nclx) {