From 099f2868701932ee99b60d19429d9c43f96dcadc Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 19 Jan 2017 11:14:47 +0100 Subject: Fix MIPS DSP configuration The patch fixes a number of bugs in code, and removes dead logic clarifying that MIPS DSP, like ARM NEON, has no runtime detecton. Change-Id: If2f4eea68da5b2eaa80b8e9c8258206d8c1b7173 Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- config.tests/unix/mips_dsp/mips_dsp.cpp | 45 -------------- config.tests/unix/mips_dsp/mips_dsp.pro | 2 - config.tests/unix/mips_dspr2/mips_dspr2.cpp | 47 --------------- config.tests/unix/mips_dspr2/mips_dspr2.pro | 2 - configure.json | 13 ++-- configure.pri | 5 +- mkspecs/common/gcc-base.conf | 2 + src/corelib/tools/qsimd_p.h | 9 +++ src/gui/image/qimage_conversions.cpp | 18 +++--- src/gui/painting/qdrawhelper.cpp | 94 ++++++++++++++--------------- src/gui/painting/qdrawhelper_mips_dsp.cpp | 15 ++++- src/gui/painting/qdrawhelper_mips_dsp_p.h | 12 ++-- 12 files changed, 94 insertions(+), 170 deletions(-) delete mode 100644 config.tests/unix/mips_dsp/mips_dsp.cpp delete mode 100644 config.tests/unix/mips_dsp/mips_dsp.pro delete mode 100644 config.tests/unix/mips_dspr2/mips_dspr2.cpp delete mode 100644 config.tests/unix/mips_dspr2/mips_dspr2.pro diff --git a/config.tests/unix/mips_dsp/mips_dsp.cpp b/config.tests/unix/mips_dsp/mips_dsp.cpp deleted file mode 100644 index 4a3ce25672..0000000000 --- a/config.tests/unix/mips_dsp/mips_dsp.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -int main(int, char**) -{ - int result; - __builtin_mips_lhx(&result, 10); - return result; -} diff --git a/config.tests/unix/mips_dsp/mips_dsp.pro b/config.tests/unix/mips_dsp/mips_dsp.pro deleted file mode 100644 index 428b106c46..0000000000 --- a/config.tests/unix/mips_dsp/mips_dsp.pro +++ /dev/null @@ -1,2 +0,0 @@ -SOURCES = mips_dsp.cpp -CONFIG -= x11 qt diff --git a/config.tests/unix/mips_dspr2/mips_dspr2.cpp b/config.tests/unix/mips_dspr2/mips_dspr2.cpp deleted file mode 100644 index 1cf95681bb..0000000000 --- a/config.tests/unix/mips_dspr2/mips_dspr2.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the config.tests of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -int main(int, char**) -{ - int result, tmp1, tmp2; - tmp1 = 10; - tmp2 = 20; - result = __builtin_mips_append (tmp1, tmp2, 10); - return result; -} diff --git a/config.tests/unix/mips_dspr2/mips_dspr2.pro b/config.tests/unix/mips_dspr2/mips_dspr2.pro deleted file mode 100644 index a938742229..0000000000 --- a/config.tests/unix/mips_dspr2/mips_dspr2.pro +++ /dev/null @@ -1,2 +0,0 @@ -SOURCES = mips_dspr2.cpp -CONFIG -= x11 qt diff --git a/configure.json b/configure.json index 7d04f0a516..e9ffc972ab 100644 --- a/configure.json +++ b/configure.json @@ -192,7 +192,7 @@ "detectPkgConfig": [ "cross_compile", "machineTuple" ], "library": [ "pkg-config" ], "getPkgConfigVariable": [ "pkg-config" ], - "neon": [ "architecture" ] + "subarch": [ "architecture" ] }, "testTypeAliases": { @@ -379,17 +379,18 @@ }, "mips_dsp": { "label": "MIPS DSP instructions", - "type": "compile", - "test": "unix/mips_dsp" + "type": "subarch", + "subarch": "dsp" }, "mips_dspr2": { "label": "MIPS DSPr2 instructions", - "type": "compile", - "test": "common/mips_dspr2" + "type": "subarch", + "subarch": "dspr2" }, "neon": { "label": "NEON instructions", - "type": "neon" + "type": "subarch", + "subarch": "neon" }, "mremap": { diff --git a/configure.pri b/configure.pri index 94aea44b13..b7dd9d460f 100644 --- a/configure.pri +++ b/configure.pri @@ -369,8 +369,9 @@ defineTest(qtConfTest_detectPkgConfig) { return(true) } -defineTest(qtConfTest_neon) { - contains($${currentConfig}.tests.architecture.subarch, "neon"): return(true) +defineTest(qtConfTest_subarch) { + subarch = $$eval($${1}.subarch) + contains($${currentConfig}.tests.architecture.subarch, $${subarch}): return(true) return(false) } diff --git a/mkspecs/common/gcc-base.conf b/mkspecs/common/gcc-base.conf index 6e043f558f..52667f130e 100644 --- a/mkspecs/common/gcc-base.conf +++ b/mkspecs/common/gcc-base.conf @@ -96,6 +96,8 @@ QMAKE_CFLAGS_AVX512VL += -mavx512vl QMAKE_CFLAGS_AVX512IFMA += -mavx512ifma QMAKE_CFLAGS_AVX512VBMI += -mavx512vbmi QMAKE_CFLAGS_NEON += -mfpu=neon +QMAKE_CFLAGS_MIPS_DSP += -mdsp +QMAKE_CFLAGS_MIPS_DSPR2 += -mdspr2 # Wrapper tools that understand .o/.a files with GIMPLE instead of machine code QMAKE_AR_LTCG = gcc-ar cqs diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index 3b6c85ca8a..f9c4d0d5ce 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -156,6 +156,15 @@ # if !defined(__ARM_FEATURE_NEON) && defined(__ARM_NEON__) # define __ARM_FEATURE_NEON // also support QT_COMPILER_SUPPORTS_HERE(NEON) # endif +#elif defined(Q_PROCESSOR_MIPS) +# define QT_COMPILER_SUPPORTS_HERE(x) (__ ## x ## __) +# define QT_FUNCTION_TARGET(x) +# if !defined(__MIPS_DSP__) && defined(__mips_dsp) && defined(Q_PROCESSOR_MIPS_32) +# define __MIPS_DSP__ +# endif +# if !defined(__MIPS_DSPR2__) && defined(__mips_dspr2) && defined(Q_PROCESSOR_MIPS_32) +# define __MIPS_DSPR2__ +# endif #elif (defined(Q_CC_INTEL) || defined(Q_CC_MSVC) \ || (defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && (__GNUC__-0) * 100 + (__GNUC_MINOR__-0) >= 409)) \ && !defined(QT_BOOTSTRAPPED) diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index c646ee96b4..9c9db9a245 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -2984,16 +2984,14 @@ static void qInitImageConversions() qimage_converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_neon; #endif -#ifdef QT_COMPILER_SUPPORTS_MIPS_DSPR2 - if (qCpuHasFeature(DSPR2)) { - extern bool convert_ARGB_to_ARGB_PM_inplace_mips_dspr2(QImageData *data, Qt::ImageConversionFlags); - qimage_inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_mips_dspr2; - - extern void convert_RGB888_to_RGB32_mips_dspr2(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); - qimage_converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_mips_dspr2; - qimage_converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_mips_dspr2; - qimage_converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_mips_dspr2; - } +#if defined(__MIPS_DSPR2__) + extern bool convert_ARGB_to_ARGB_PM_inplace_mips_dspr2(QImageData *data, Qt::ImageConversionFlags); + qimage_inplace_converter_map[QImage::Format_ARGB32][QImage::Format_ARGB32_Premultiplied] = convert_ARGB_to_ARGB_PM_inplace_mips_dspr2; + + extern void convert_RGB888_to_RGB32_mips_dspr2(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); + qimage_converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_mips_dspr2; + qimage_converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_mips_dspr2; + qimage_converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_mips_dspr2; #endif } diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 298304c4ef..7b3e1b991d 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -1539,12 +1539,8 @@ static const uint *QT_FASTCALL fetchUntransformedRGB16(uint *buffer, const Opera int length) { const quint16 *scanLine = (const quint16 *)data->texture.scanLine(y) + x; -#ifdef QT_COMPILER_SUPPORTS_MIPS_DSPR2 - qConvertRgb16To32_asm_mips_dspr2(buffer, scanLine, length); -#else for (int i = 0; i < length; ++i) buffer[i] = qConvertRgb16To32(scanLine[i]); -#endif return buffer; } @@ -6030,7 +6026,7 @@ void qt_memfill16(quint16 *dest, quint16 color, int count) qt_memfill_template(dest, color, count); } #endif -#if !defined(__SSE2__) && !defined(__ARM_NEON__) && !defined(__mips_dsp) +#if !defined(__SSE2__) && !defined(__ARM_NEON__) && !defined(__MIPS_DSP__) void qt_memfill32(quint32 *dest, quint32 color, int count) { qt_memfill_template(dest, color, count); @@ -6222,52 +6218,50 @@ static void qInitDrawhelperFunctions() qMemRotateFunctions[QImage::Format_RGB16][0] = qt_memrotate90_16_neon; qMemRotateFunctions[QImage::Format_RGB16][2] = qt_memrotate270_16_neon; #endif - -#endif - -#if defined(QT_COMPILER_SUPPORTS_MIPS_DSP) || defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2) - if (qCpuHasFeature(DSP) && qCpuHasFeature(DSPR2)) { - // Composition functions are all DSP r1 - qt_functionForMode_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_asm_mips_dsp; - qt_functionForMode_C[QPainter::CompositionMode_Source] = comp_func_Source_mips_dsp; - qt_functionForMode_C[QPainter::CompositionMode_DestinationOver] = comp_func_DestinationOver_mips_dsp; - qt_functionForMode_C[QPainter::CompositionMode_SourceIn] = comp_func_SourceIn_mips_dsp; - qt_functionForMode_C[QPainter::CompositionMode_DestinationIn] = comp_func_DestinationIn_mips_dsp; - qt_functionForMode_C[QPainter::CompositionMode_DestinationOut] = comp_func_DestinationOut_mips_dsp; - qt_functionForMode_C[QPainter::CompositionMode_SourceAtop] = comp_func_SourceAtop_mips_dsp; - qt_functionForMode_C[QPainter::CompositionMode_DestinationAtop] = comp_func_DestinationAtop_mips_dsp; - qt_functionForMode_C[QPainter::CompositionMode_Xor] = comp_func_XOR_mips_dsp; - qt_functionForMode_C[QPainter::CompositionMode_SourceOut] = comp_func_SourceOut_mips_dsp; - - qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_mips_dsp; - qt_functionForModeSolid_C[QPainter::CompositionMode_DestinationOver] = comp_func_solid_DestinationOver_mips_dsp; - qt_functionForModeSolid_C[QPainter::CompositionMode_SourceIn] = comp_func_solid_SourceIn_mips_dsp; - qt_functionForModeSolid_C[QPainter::CompositionMode_DestinationIn] = comp_func_solid_DestinationIn_mips_dsp; - qt_functionForModeSolid_C[QPainter::CompositionMode_SourceAtop] = comp_func_solid_SourceAtop_mips_dsp; - qt_functionForModeSolid_C[QPainter::CompositionMode_DestinationAtop] = comp_func_solid_DestinationAtop_mips_dsp; - qt_functionForModeSolid_C[QPainter::CompositionMode_Xor] = comp_func_solid_XOR_mips_dsp; - qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOut] = comp_func_solid_SourceOut_mips_dsp; - - qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_mips_dsp; - qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_mips_dsp; - qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_mips_dsp; - qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_mips_dsp; - - destFetchProc[QImage::Format_ARGB32] = qt_destFetchARGB32_mips_dsp; - - destStoreProc[QImage::Format_ARGB32] = qt_destStoreARGB32_mips_dsp; - - sourceFetchUntransformed[QImage::Format_RGB888] = qt_fetchUntransformed_888_mips_dsp; - sourceFetchUntransformed[QImage::Format_RGB444] = qt_fetchUntransformed_444_mips_dsp; - sourceFetchUntransformed[QImage::Format_ARGB8565_Premultiplied] = qt_fetchUntransformed_argb8565_premultiplied_mips_dsp; - -#if defined(QT_COMPILER_SUPPORTS_MIPS_DSPR2) - qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16_mips_dspr2; +#endif // defined(__ARM_NEON__) + +#if defined(__MIPS_DSP__) + // Composition functions are all DSP r1 + qt_functionForMode_C[QPainter::CompositionMode_SourceOver] = comp_func_SourceOver_asm_mips_dsp; + qt_functionForMode_C[QPainter::CompositionMode_Source] = comp_func_Source_mips_dsp; + qt_functionForMode_C[QPainter::CompositionMode_DestinationOver] = comp_func_DestinationOver_mips_dsp; + qt_functionForMode_C[QPainter::CompositionMode_SourceIn] = comp_func_SourceIn_mips_dsp; + qt_functionForMode_C[QPainter::CompositionMode_DestinationIn] = comp_func_DestinationIn_mips_dsp; + qt_functionForMode_C[QPainter::CompositionMode_DestinationOut] = comp_func_DestinationOut_mips_dsp; + qt_functionForMode_C[QPainter::CompositionMode_SourceAtop] = comp_func_SourceAtop_mips_dsp; + qt_functionForMode_C[QPainter::CompositionMode_DestinationAtop] = comp_func_DestinationAtop_mips_dsp; + qt_functionForMode_C[QPainter::CompositionMode_Xor] = comp_func_XOR_mips_dsp; + qt_functionForMode_C[QPainter::CompositionMode_SourceOut] = comp_func_SourceOut_mips_dsp; + + qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOver] = comp_func_solid_SourceOver_mips_dsp; + qt_functionForModeSolid_C[QPainter::CompositionMode_DestinationOver] = comp_func_solid_DestinationOver_mips_dsp; + qt_functionForModeSolid_C[QPainter::CompositionMode_SourceIn] = comp_func_solid_SourceIn_mips_dsp; + qt_functionForModeSolid_C[QPainter::CompositionMode_DestinationIn] = comp_func_solid_DestinationIn_mips_dsp; + qt_functionForModeSolid_C[QPainter::CompositionMode_SourceAtop] = comp_func_solid_SourceAtop_mips_dsp; + qt_functionForModeSolid_C[QPainter::CompositionMode_DestinationAtop] = comp_func_solid_DestinationAtop_mips_dsp; + qt_functionForModeSolid_C[QPainter::CompositionMode_Xor] = comp_func_solid_XOR_mips_dsp; + qt_functionForModeSolid_C[QPainter::CompositionMode_SourceOut] = comp_func_solid_SourceOut_mips_dsp; + + qBlendFunctions[QImage::Format_RGB32][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_mips_dsp; + qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_RGB32] = qt_blend_rgb32_on_rgb32_mips_dsp; + qBlendFunctions[QImage::Format_RGB32][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_mips_dsp; + qBlendFunctions[QImage::Format_ARGB32_Premultiplied][QImage::Format_ARGB32_Premultiplied] = qt_blend_argb32_on_argb32_mips_dsp; + + destFetchProc[QImage::Format_ARGB32] = qt_destFetchARGB32_mips_dsp; + + destStoreProc[QImage::Format_ARGB32] = qt_destStoreARGB32_mips_dsp; + + sourceFetchUntransformed[QImage::Format_RGB888] = qt_fetchUntransformed_888_mips_dsp; + sourceFetchUntransformed[QImage::Format_RGB444] = qt_fetchUntransformed_444_mips_dsp; + sourceFetchUntransformed[QImage::Format_ARGB8565_Premultiplied] = qt_fetchUntransformed_argb8565_premultiplied_mips_dsp; + +#if defined(__MIPS_DSPR2__) + qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16_mips_dspr2; + sourceFetchUntransformed[QImage::Format_RGB16] = qt_fetchUntransformedRGB16_mips_dspr2; #else - qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16_mips_dsp; -#endif // QT_COMPILER_SUPPORTS_MIPS_DSPR2 - } -#endif // QT_COMPILER_SUPPORTS_MIPS_DSP || QT_COMPILER_SUPPORTS_MIPS_DSPR2 + qBlendFunctions[QImage::Format_RGB16][QImage::Format_RGB16] = qt_blend_rgb16_on_rgb16_mips_dsp; +#endif // defined(__MIPS_DSPR2__) +#endif // defined(__MIPS_DSP__) } // Ensure initialization if this object file is linked. diff --git a/src/gui/painting/qdrawhelper_mips_dsp.cpp b/src/gui/painting/qdrawhelper_mips_dsp.cpp index 783e481296..e92a6606de 100644 --- a/src/gui/painting/qdrawhelper_mips_dsp.cpp +++ b/src/gui/painting/qdrawhelper_mips_dsp.cpp @@ -113,7 +113,7 @@ void qt_blend_rgb32_on_rgb32_mips_dsp(uchar *destPixels, int dbpl, } } -#if defined QT_COMPILER_SUPPORTS_MIPS_DSPR2 +#if defined(__MIPS_DSPR2__) void qt_blend_rgb16_on_rgb16_mips_dspr2(uchar *destPixels, int dbpl, const uchar *srcPixels, int sbpl, int w, int h, @@ -521,4 +521,17 @@ const uint * QT_FASTCALL qt_fetchUntransformed_argb8565_premultiplied_mips_dsp ( return buffer; } +#if defined(__MIPS_DSPR2__) +extern "C" void qConvertRgb16To32_asm_mips_dspr2(quint32 *dest, const quint16 *src, int length); + +const uint *QT_FASTCALL qt_fetchUntransformedRGB16_mips_dspr2(uint *buffer, const Operator *, + const QSpanData *data, int y, int x, + int length) +{ + const quint16 *scanLine = (const quint16 *)data->texture.scanLine(y) + x; + qConvertRgb16To32_asm_mips_dspr2(buffer, scanLine, length); + return buffer; +} +#endif + QT_END_NAMESPACE diff --git a/src/gui/painting/qdrawhelper_mips_dsp_p.h b/src/gui/painting/qdrawhelper_mips_dsp_p.h index 86773ad25f..36c4af2732 100644 --- a/src/gui/painting/qdrawhelper_mips_dsp_p.h +++ b/src/gui/painting/qdrawhelper_mips_dsp_p.h @@ -192,12 +192,9 @@ const uint * QT_FASTCALL qt_fetchUntransformed_argb8565_premultiplied_mips_dsp ( const QSpanData *data, int y, int x, int length); -#endif // QT_COMPILER_SUPPORTS_MIPS_DSP - -#ifdef QT_COMPILER_SUPPORTS_MIPS_DSPR2 -extern "C" void qConvertRgb16To32_asm_mips_dspr2(quint32 *dest, const quint16 *src, int length); +#if defined(__MIPS_DSPR2__) extern "C" void qt_blend_rgb16_on_rgb16_mips_dspr2_asm(quint16 *dest, const quint16 *src, int length, uint const_alpha); @@ -206,7 +203,12 @@ void qt_blend_rgb16_on_rgb16_mips_dspr2(uchar *destPixels, int dbpl, int w, int h, int const_alpha); -#endif // QT_COMPILER_SUPPORTS_MIPS_DSPR2 +const uint *QT_FASTCALL qt_fetchUntransformedRGB16_mips_dspr2(uint *buffer, const Operator *, + const QSpanData *data, int y, int x, + int length); +#endif // defined(__MIPS_DSPR2__) + +#endif // QT_COMPILER_SUPPORTS_MIPS_DSP QT_END_NAMESPACE -- cgit v1.2.3 From 72f49ef46a3426471b3c2102566d7d04390217d2 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 26 Jan 2017 19:38:20 -0800 Subject: MSVC: Fix use of POPCNT instruction without CPU check The __popcnt family of intrinsics with MSVC generates directly the POPCNT instruction and are documented to do so: https://msdn.microsoft.com/en-us/library/bb385231.aspx So we can't use __popcnt unless the target processor supports it. [ChangeLog][Windows] Fixed a bug that caused applications to crash with "Illegal instruction" faults when compiled with Visual Studio and run on some older processors. Task-number: QTBUG-58446 Change-Id: I445bb15619f6401494e8fffd149d83bd2a7e3376 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/tools/qalgorithms.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h index fb7031ce71..c0f7709fec 100644 --- a/src/corelib/tools/qalgorithms.h +++ b/src/corelib/tools/qalgorithms.h @@ -638,6 +638,17 @@ Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW { return qt_builtin_clz(v) - 16U; } + +// Neither MSVC nor the Intel compiler define a macro for the POPCNT processor +// feature, so we're using either the SSE4.2 or the AVX macro as a proxy (Clang +// does define the macro). It's incorrect for two reasons: +// 1. It's a separate bit in CPUID, so a processor could implement SSE4.2 and +// not POPCNT, but that's unlikely to happen. +// 2. There are processors that support POPCNT but not AVX (Intel Nehalem +// architecture), but unlike the other compilers, MSVC has no option +// to generate code for those processors. +// So it's an acceptable compromise. +#if defined(__AVX__) || defined(__SSE4_2__) || defined(__POPCNT__) #define QALGORITHMS_USE_BUILTIN_POPCOUNT Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW { @@ -658,6 +669,8 @@ Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW return __popcnt64(v); } #endif // MSVC 64bit +#endif // __AVX__ || __SSE4_2__ || __POPCNT__ + #endif // MSVC #endif // QT_HAS_CONSTEXPR_BUILTINS -- cgit v1.2.3 From e0ecdebaa18b81dfe6690e688b7aa44b8b559c0c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 26 Jan 2017 15:02:04 -0800 Subject: Unbreak the build with ICC on Windows Commit 52d64fca662d0e488801fc40dffdc0a732cfdbd5 made qlibraryinfo.obj be compiled with an extra -D argument, but that doesn't take effect since a precompiled header is in effect. Warning #673: the initial sequence of preprocessing directives is not compatible with those of precompiled header file "qmake_pch.pchi" qlibraryinfo.cpp(61): catastrophic error: cannot open source file "qconfig.cpp" Change-Id: Iab7c358838e1487387a2fffd149d74a9aa2be338 Reviewed-by: Oswald Buddenhagen --- qmake/Makefile.win32 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qmake/Makefile.win32 b/qmake/Makefile.win32 index c2e32dfc20..bb1f8aaabc 100644 --- a/qmake/Makefile.win32 +++ b/qmake/Makefile.win32 @@ -203,12 +203,12 @@ qmake_pch.obj: {$(SOURCE_PATH)\src\corelib\json}.cpp{}.obj:: $(CXX) $(CXXFLAGS) $< -# Make sure qstring_compat.obj isn't compiled with PCH enabled +# Make sure qstring_compat.obj and qlibraryinfo.obj aren't compiled with PCH enabled qstring_compat.obj: $(SOURCE_PATH)\src\corelib\tools\qstring_compat.cpp $(CXX) -c $(CXXFLAGS_BARE) $(SOURCE_PATH)\src\corelib\tools\qstring_compat.cpp qlibraryinfo.obj: $(SOURCE_PATH)\src\corelib\global\qlibraryinfo.cpp - $(CXX) $(CXXFLAGS) -DQT_BUILD_QMAKE_BOOTSTRAP $(SOURCE_PATH)\src\corelib\global\qlibraryinfo.cpp + $(CXX) $(CXXFLAGS_BARE) -DQT_BUILD_QMAKE_BOOTSTRAP $(SOURCE_PATH)\src\corelib\global\qlibraryinfo.cpp qlibraryinfo_final.obj: $(SOURCE_PATH)\src\corelib\global\qlibraryinfo.cpp $(BUILD_PATH)\src\corelib\global\qconfig.cpp $(CXX) $(CXXFLAGS) -Foqlibraryinfo_final.obj $(SOURCE_PATH)\src\corelib\global\qlibraryinfo.cpp -- cgit v1.2.3 From 77b33e4b856c8c60993c0d65ad32c146e98c6701 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 17 Dec 2016 14:50:45 -0800 Subject: Re-fix Clang-cl and ICC support on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of using the actual compiler version to determine which C++11 features to enable, let's just use the Mirosoft compiler version that the actual compiler is claiming compatibility with. That is because the limiting factor is often the standard library, not the compiler itself. This will cause some features that do not depend on the library to also be disabled, but oh well. Better upgrade your Visual Studio version instead. Task-number: QTBUG-57696 Change-Id: I3e4e5051937c40319d6efffd14912cd4fdab25fb Reviewed-by: Friedemann Kleint Reviewed-by: Sérgio Martins --- src/corelib/global/qcompilerdetection.h | 34 +++------------------------------ 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index c0f14e0f03..3b83d81f02 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -563,7 +563,7 @@ # endif #endif -#ifdef Q_CC_INTEL +#if defined(Q_CC_INTEL) && !defined(Q_CC_MSVC) # define Q_COMPILER_RESTRICTED_VLA # define Q_COMPILER_VARIADIC_MACROS // C++11 feature supported as an extension in other modes, too # define Q_COMPILER_THREADSAFE_STATICS @@ -652,7 +652,7 @@ # endif #endif -#if defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) +#if defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) && !defined(Q_CC_MSVC) /* General C++ features */ # define Q_COMPILER_RESTRICTED_VLA # define Q_COMPILER_THREADSAFE_STATICS @@ -898,7 +898,7 @@ # endif #endif -#if defined(Q_CC_MSVC) && !defined(Q_CC_INTEL) +#if defined(Q_CC_MSVC) # if defined(__cplusplus) # if _MSC_VER >= 1400 /* C++11 features supported in VC8 = VC2005: */ @@ -1044,34 +1044,6 @@ # define __USE_CONSTEXPR 1 # define __USE_NOEXCEPT 1 # endif -# if defined(Q_CC_MSVC) && defined(Q_CC_CLANG) -// Clang and the Intel compiler support more C++ features than the Microsoft compiler -// so make sure we don't enable them if the MS headers aren't properly adapted. -# ifndef _HAS_CONSTEXPR -# undef Q_COMPILER_CONSTEXPR -# endif -# ifndef _HAS_DECLTYPE -# undef Q_COMPILER_DECLTYPE -# endif -# ifndef _HAS_INITIALIZER_LISTS -# undef Q_COMPILER_INITIALIZER_LISTS -# endif -# ifndef _HAS_NULLPTR_T -# undef Q_COMPILER_NULLPTR -# endif -# ifndef _HAS_RVALUE_REFERENCES -# undef Q_COMPILER_RVALUE_REFS -# endif -# ifndef _HAS_SCOPED_ENUM -# undef Q_COMPILER_CLASS_ENUM -# endif -# ifndef _HAS_TEMPLATE_ALIAS -# undef Q_COMPILER_TEMPLATE_ALIAS -# endif -# ifndef _HAS_VARIADIC_TEMPLATES -# undef Q_COMPILER_VARIADIC_TEMPLATES -# endif -# endif # if defined(Q_COMPILER_THREADSAFE_STATICS) && defined(Q_OS_MAC) // Apple's low-level implementation of the C++ support library // (libc++abi.dylib, shared between libstdc++ and libc++) has deadlocks. The -- cgit v1.2.3 From bec3658e19a8028fbc50c6cca9615e5ca052adb2 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 26 Jan 2017 15:12:42 +0100 Subject: Fix build with -no-feature-animation Change-Id: Ieecb9cdbf4373e295148ae5b3d59c43aaf46175e Reviewed-by: Lars Knoll --- src/widgets/styles/qstylesheetstyle.cpp | 5 ++++- src/widgets/styles/qwindowsstyle.cpp | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index d9d270643c..9be19b2679 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -3916,10 +3916,12 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q if (pb->minimum == 0 && pb->maximum == 0) { int chunkCount = fillWidth/chunkWidth; int offset = 0; +#if QT_CONFIG(animation) if (QProgressStyleAnimation *animation = qobject_cast(d->animation(opt->styleObject))) offset = animation->animationStep() * 8 % rect.width(); else d->startAnimation(new QProgressStyleAnimation(d->animationFps, opt->styleObject)); +#endif int x = reverse ? r.left() + r.width() - offset - chunkWidth : r.x() + offset; while (chunkCount > 0) { r.setRect(x, rect.y(), chunkWidth, rect.height()); @@ -3950,8 +3952,9 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q subRule.drawRule(p, r); x += reverse ? -chunkWidth : chunkWidth; } - +#if QT_CONFIG(animation) d->stopAnimation(opt->styleObject); +#endif } p->restore(); diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index f9370a2cc7..0ce8dde74c 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -1729,10 +1729,12 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai int step = 0; int chunkCount = w / unit_width + 1; +#if QT_CONFIG(animation) if (QProgressStyleAnimation *animation = qobject_cast(d->animation(opt->styleObject))) step = (animation->animationStep() / 3) % chunkCount; else d->startAnimation(new QProgressStyleAnimation(d->animationFps, opt->styleObject)); +#endif int chunksInRow = 5; int myY = pbBits.rect.y(); int myHeight = pbBits.rect.height(); @@ -1766,7 +1768,9 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai p->restore(); //restore state } else { +#if QT_CONFIG(animation) d->stopAnimation(opt->styleObject); +#endif QCommonStyle::drawControl(ce, opt, p, widget); } } -- cgit v1.2.3 From 0159cbb1a29f7a1fd6569948def3fdf42b3e3798 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 27 Jan 2017 11:07:14 -0800 Subject: Move the declaration of SSE3 & newer macros above their use Change-Id: I445bb15619f6401494e8fffd149db66da3405b48 Reviewed-by: Allan Sandfeld Jensen --- src/corelib/tools/qsimd_p.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index f9c4d0d5ce..ab9f383803 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -181,6 +181,20 @@ # define QT_FUNCTION_TARGET(x) #endif +#if defined(Q_CC_MSVC) && (defined(_M_AVX) || defined(__AVX__)) +// Visual Studio defines __AVX__ when /arch:AVX is passed, but not the earlier macros +// See: https://msdn.microsoft.com/en-us/library/b0084kay.aspx +// SSE2 is handled by _M_IX86_FP below +# define __SSE3__ 1 +# define __SSSE3__ 1 +// no Intel CPU supports SSE4a, so don't define it +# define __SSE4_1__ 1 +# define __SSE4_2__ 1 +# ifndef __AVX__ +# define __AVX__ 1 +# endif +#endif + // SSE intrinsics #define QT_FUNCTION_TARGET_STRING_SSE2 "sse2" #if defined(__SSE2__) || (defined(QT_COMPILER_SUPPORTS_SSE2) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) @@ -229,20 +243,6 @@ #if defined(__AVX__) || (defined(QT_COMPILER_SUPPORTS_AVX) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) // immintrin.h is the ultimate header, we don't need anything else after this #include - -# if defined(Q_CC_MSVC) && (defined(_M_AVX) || defined(__AVX__)) -// MS Visual Studio 2010 has no macro pre-defined to identify the use of /arch:AVX -// MS Visual Studio 2013 adds it: __AVX__ -// See: http://connect.microsoft.com/VisualStudio/feedback/details/605858/arch-avx-should-define-a-predefined-macro-in-x64-and-set-a-unique-value-for-m-ix86-fp-in-win32 -# define __SSE3__ 1 -# define __SSSE3__ 1 -// no Intel CPU supports SSE4a, so don't define it -# define __SSE4_1__ 1 -# define __SSE4_2__ 1 -# ifndef __AVX__ -# define __AVX__ 1 -# endif -# endif #endif #define QT_FUNCTION_TARGET_STRING_AVX512F "avx512f" -- cgit v1.2.3 From c20fa2879ea4dd0e40f596256dfe32bae0ff600a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 27 Jan 2017 11:15:19 -0800 Subject: Regroup the x86 QT_FUNCTION_TARGET_STRING_xxxx macros Easier to have an overview of them. Change-Id: I445bb15619f6401494e8fffd149db6dec4851f6d Reviewed-by: Allan Sandfeld Jensen --- src/corelib/tools/qsimd_p.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index ab9f383803..be53c51c48 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -196,7 +196,6 @@ #endif // SSE intrinsics -#define QT_FUNCTION_TARGET_STRING_SSE2 "sse2" #if defined(__SSE2__) || (defined(QT_COMPILER_SUPPORTS_SSE2) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) #if defined(QT_LINUXBASE) /// this is an evil hack - the posix_memalign declaration in LSB @@ -214,37 +213,38 @@ #endif // SSE3 intrinsics -#define QT_FUNCTION_TARGET_STRING_SSE3 "sse3" #if defined(__SSE3__) || (defined(QT_COMPILER_SUPPORTS_SSE3) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) #include #endif // SSSE3 intrinsics -#define QT_FUNCTION_TARGET_STRING_SSSE3 "ssse3" #if defined(__SSSE3__) || (defined(QT_COMPILER_SUPPORTS_SSSE3) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) #include #endif // SSE4.1 intrinsics -#define QT_FUNCTION_TARGET_STRING_SSE4_1 "sse4.1" #if defined(__SSE4_1__) || (defined(QT_COMPILER_SUPPORTS_SSE4_1) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) #include #endif // SSE4.2 intrinsics -#define QT_FUNCTION_TARGET_STRING_SSE4_2 "sse4.2" #if defined(__SSE4_2__) || (defined(QT_COMPILER_SUPPORTS_SSE4_2) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) #include #endif // AVX intrinsics -#define QT_FUNCTION_TARGET_STRING_AVX "avx" -#define QT_FUNCTION_TARGET_STRING_AVX2 "avx2" #if defined(__AVX__) || (defined(QT_COMPILER_SUPPORTS_AVX) && defined(QT_COMPILER_SUPPORTS_SIMD_ALWAYS)) // immintrin.h is the ultimate header, we don't need anything else after this #include #endif +#define QT_FUNCTION_TARGET_STRING_SSE2 "sse2" +#define QT_FUNCTION_TARGET_STRING_SSE3 "sse3" +#define QT_FUNCTION_TARGET_STRING_SSSE3 "ssse3" +#define QT_FUNCTION_TARGET_STRING_SSE4_1 "sse4.1" +#define QT_FUNCTION_TARGET_STRING_SSE4_2 "sse4.2" +#define QT_FUNCTION_TARGET_STRING_AVX "avx" +#define QT_FUNCTION_TARGET_STRING_AVX2 "avx2" #define QT_FUNCTION_TARGET_STRING_AVX512F "avx512f" #define QT_FUNCTION_TARGET_STRING_AVX512CD "avx512cd" #define QT_FUNCTION_TARGET_STRING_AVX512ER "avx512er" -- cgit v1.2.3 From e2c0d1ea2e0c35a3899283237ede02b4f49aa5b3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 17 Jan 2017 10:40:01 -0800 Subject: Read the .ini file back in text mode Because on Windows, the .ini files are saved with CRLF, but the files in the Qt resource are just LF (.gitattributes makes them so). Task-number: QTBUG-25446 Change-Id: I5eab0d9620bd1ba675b0a87c554f62cef0f98fcc Reviewed-by: Mitch Curtis Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qsettings/tst_qsettings.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index dadf4b612e..f94349fd02 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -2315,14 +2315,14 @@ void tst_QSettings::setIniCodec() { QFile inFile(settings4.fileName()); - inFile.open(QIODevice::ReadOnly); + inFile.open(QIODevice::ReadOnly | QIODevice::Text); actualContents4 = inFile.readAll(); inFile.close(); } { QFile inFile(settings5.fileName()); - inFile.open(QIODevice::ReadOnly); + inFile.open(QIODevice::ReadOnly | QIODevice::Text); actualContents5 = inFile.readAll(); inFile.close(); } @@ -2330,9 +2330,6 @@ void tst_QSettings::setIniCodec() QConfFile::clearCache(); -#ifdef Q_OS_WIN - QEXPECT_FAIL("", "QTBUG-25446", Abort); -#endif QCOMPARE(actualContents4, expeContents4); QCOMPARE(actualContents5, expeContents5); -- cgit v1.2.3 From cc786350ae3e95c1e001159f03ebf284487acdad Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 24 Nov 2016 09:27:52 +0100 Subject: qsslsocket_openssl_symbols.cpp: Fix signedness warning in DEFINEFUNC2 Fix warning: qsslsocket_openssl_symbols.cpp157:78:warning: implicit conversion changes signedness: 'int' to 'unsigned long' note: expanded from macro 'DEFINEFUNC2' Amends change 2cf63c71ebe139890526057dcc51b24ea6df6c30 Change-Id: I694c5199d272d05f0070288af2e00b6fce42fc91 Reviewed-by: Timur Pocheptsov (cherry picked from commit 38a446b69e95423d8d42d33b30b3154caa475e09) --- src/network/ssl/qsslsocket_openssl_symbols.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 88fed69d3a..2a0d746fde 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -154,7 +154,7 @@ DEFINEFUNC(int, BN_num_bits, const BIGNUM *a, a, return 0, return) #if OPENSSL_VERSION_NUMBER >= 0x10100000L DEFINEFUNC2(int, BN_is_word, BIGNUM *a, a, BN_ULONG w, w, return 0, return) #endif -DEFINEFUNC2(BN_ULONG, BN_mod_word, const BIGNUM *a, a, BN_ULONG w, w, return -1, return) +DEFINEFUNC2(BN_ULONG, BN_mod_word, const BIGNUM *a, a, BN_ULONG w, w, return static_cast(-1), return) #ifndef OPENSSL_NO_EC DEFINEFUNC(const EC_GROUP*, EC_KEY_get0_group, const EC_KEY* k, k, return 0, return) DEFINEFUNC(int, EC_GROUP_get_degree, const EC_GROUP* g, g, return 0, return) -- cgit v1.2.3 From 41e4b4de91227c12e50559ae74d3834e91eebc0b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 20 Jan 2017 14:55:41 +0100 Subject: QtGui/painting benchmark test: Fix Clang warning about uninitialized value benchmarktests.h:323:18: warning: field 'm_as_pixmap' is uninitialized when used here [-Wuninitialized] benchmarktests.h:371:18: warning: field 'm_as_pixmap' is uninitialized when used here [-Wuninitialized] benchmarktests.h:417:18: warning: field 'm_as_pixmap' is uninitialized when used here [-Wuninitialized] Change-Id: Ica496e3baa19e0701c64222ce8ab92ec94178db7 Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/benchmarks/gui/painting/qtbench/benchmarktests.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/benchmarks/gui/painting/qtbench/benchmarktests.h b/tests/benchmarks/gui/painting/qtbench/benchmarktests.h index c69fca68bc..e4b98336c7 100644 --- a/tests/benchmarks/gui/painting/qtbench/benchmarktests.h +++ b/tests/benchmarks/gui/painting/qtbench/benchmarktests.h @@ -320,7 +320,7 @@ public: DrawScaledImage(const QImage &image, qreal scale, bool asPixmap) : Benchmark(QSize(image.width(), image.height())), m_image(image), - m_type(m_as_pixmap ? "Pixmap" : "Image"), + m_type(asPixmap ? "Pixmap" : "Image"), m_scale(scale), m_as_pixmap(asPixmap) { @@ -368,7 +368,7 @@ public: DrawTransformedImage(const QImage &image, bool asPixmap) : Benchmark(QSize(image.width(), image.height())), m_image(image), - m_type(m_as_pixmap ? "Pixmap" : "Image"), + m_type(asPixmap ? "Pixmap" : "Image"), m_as_pixmap(asPixmap) { m_pixmap = QPixmap::fromImage(m_image); @@ -414,7 +414,7 @@ public: DrawImage(const QImage &image, bool asPixmap) : Benchmark(QSize(image.width(), image.height())), m_image(image), - m_type(m_as_pixmap ? "Pixmap" : "Image"), + m_type(asPixmap ? "Pixmap" : "Image"), m_as_pixmap(asPixmap) { m_pixmap = QPixmap::fromImage(image); -- cgit v1.2.3 From 07218826e5b5b03b06d373764262a46ce4be51a7 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 2 Jan 2017 10:58:10 +0100 Subject: Doc: Normalize \since usage Although it's permitted to specify the project name together with a version number for \since, it's unnecessary for Qt classes and functions. This change also normalizes the version formatting: '.' Change-Id: Ie5a43662077d13c31e241bcde8a7a2849d27d330 Reviewed-by: Leena Miettinen --- src/corelib/global/qglobal.cpp | 6 +++--- src/corelib/tools/qstring.cpp | 2 +- src/corelib/tools/qstringlist.cpp | 2 +- src/network/socket/qnativesocketengine.cpp | 8 ++++++-- src/widgets/graphicsview/qgraphicsitem.cpp | 2 +- src/widgets/widgets/qmainwindow.cpp | 2 +- src/widgets/widgets/qtabbar.cpp | 2 +- 7 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index f6053ce622..bc6560ddae 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -131,7 +131,7 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in /*! \fn QFlag::QFlag(uint value) - \since Qt 5.3 + \since 5.3 Constructs a QFlag object that stores the given \a value. */ @@ -145,7 +145,7 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in /*! \fn QFlag::QFlag(ushort value) - \since Qt 5.3 + \since 5.3 Constructs a QFlag object that stores the given \a value. */ @@ -158,7 +158,7 @@ Q_STATIC_ASSERT_X(QT_POINTER_SIZE == sizeof(void *), "QT_POINTER_SIZE defined in /*! \fn QFlag::operator uint() const - \since Qt 5.3 + \since 5.3 Returns the value stored by the QFlag object. */ diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 9a3c05ac85..aae4aab4c9 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -10107,7 +10107,7 @@ bool QStringRef::endsWith(const QStringRef &str, Qt::CaseSensitivity cs) const */ /*! \fn bool QStringRef::contains(QLatin1String str, Qt::CaseSensitivity cs) const - \since 4,8 + \since 4.8 \overload contains() Returns \c true if this string reference contains an occurrence of diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index 88ceae20b9..75ff934f15 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -716,7 +716,7 @@ int QtPrivate::QStringList_lastIndexOf(const QStringList *that, const QRegularEx /*! \fn int QStringList::removeDuplicates() - \since 4.5 + \since 4.5 This function removes duplicate entries from a list. The entries do not have to be sorted. They will retain their diff --git a/src/network/socket/qnativesocketengine.cpp b/src/network/socket/qnativesocketengine.cpp index 928c7fc68f..b56d460b8c 100644 --- a/src/network/socket/qnativesocketengine.cpp +++ b/src/network/socket/qnativesocketengine.cpp @@ -761,7 +761,9 @@ bool QNativeSocketEngine::leaveMulticastGroup(const QHostAddress &groupAddress, return d->nativeLeaveMulticastGroup(groupAddress, iface); } -/*! \since 4.8 */ +/*! + \since 4.8 +*/ QNetworkInterface QNativeSocketEngine::multicastInterface() const { Q_D(const QNativeSocketEngine); @@ -770,7 +772,9 @@ QNetworkInterface QNativeSocketEngine::multicastInterface() const return d->nativeMulticastInterface(); } -/*! \since 4.8 */ +/*! + \since 4.8 +*/ bool QNativeSocketEngine::setMulticastInterface(const QNetworkInterface &iface) { Q_D(QNativeSocketEngine); diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 6124796073..c9eea6928a 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -6596,7 +6596,7 @@ QGraphicsItem *QGraphicsItem::commonAncestorItem(const QGraphicsItem *other) con } /*! - \since 4,4 + \since 4.4 Returns \c true if this item is currently under the mouse cursor in one of the views; otherwise, false is returned. diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index abfdfbea9b..c9349ac72d 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -676,7 +676,7 @@ void QMainWindow::setCentralWidget(QWidget *widget) The ownership of the removed widget is passed to the caller. - \since Qt 5.2 + \since 5.2 */ QWidget *QMainWindow::takeCentralWidget() { diff --git a/src/widgets/widgets/qtabbar.cpp b/src/widgets/widgets/qtabbar.cpp index 6e34198f67..35d9498413 100644 --- a/src/widgets/widgets/qtabbar.cpp +++ b/src/widgets/widgets/qtabbar.cpp @@ -1448,7 +1448,7 @@ static QString computeElidedText(Qt::TextElideMode mode, const QString &text) /*! Returns the minimum tab size hint for the tab at position \a index. - \since Qt 5.0 + \since 5.0 */ QSize QTabBar::minimumTabSizeHint(int index) const -- cgit v1.2.3 From 39fb26376c9718a8d09180c5947c2efec0d01adc Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 31 Jan 2017 13:19:03 +0100 Subject: Remove unused logging category from QOpenGLFunctions Change-Id: I54b533036f24ee9bd63004d1c5513f847e12065d Reviewed-by: Andy Nichols --- src/gui/opengl/qopenglfunctions.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index ad8b19a2bc..e724efab37 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #ifdef Q_OS_INTEGRITY #include @@ -57,9 +56,6 @@ QT_BEGIN_NAMESPACE -Q_LOGGING_CATEGORY(lcGLES3, "qt.opengl.es3") - - #define QT_OPENGL_COUNT_FUNCTIONS(ret, name, args) +1 #define QT_OPENGL_FUNCTION_NAMES(ret, name, args) \ "gl"#name"\0" -- cgit v1.2.3 From 098d87c63fb638db619808af8b86c043354f62c5 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 27 Jan 2017 16:41:37 +0100 Subject: Fix clipping error on some RTL text There was a false assumption that the bidi level of text is only used for visualizing the text, not for calculating its bounding box. But the bidi level is required for shaping (indeed many OpenType rules check for reading direction) and the glyphs used to represent a given text may be different based on its directionality. The effect would be that the bounding rect we calculated for text would sometimes be too small for RTL text, and we would end up clipping pixels. [ChangeLog][QtGui][Text] Fixed clipping errors and too small bounding rects for some right-to-left text. Task-number: QTBUG-48005 Change-Id: Idd12ae1b0033d518034b582204ba47ae41795293 Reviewed-by: Lars Knoll --- src/gui/painting/qpainter.cpp | 1 - src/gui/text/qfontmetrics.cpp | 6 ------ 2 files changed, 7 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index 74b961f042..083e68fcdb 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7570,7 +7570,6 @@ start_lengthVariant: lineWidth = qMax(0, r.width()); if(!wordwrap) tf |= Qt::TextIncludeTrailingSpaces; - textLayout.engine()->ignoreBidi = bool(tf & Qt::TextDontPrint); textLayout.beginLayout(); qreal leading = fm.leading(); diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index aca59d0288..8067969f56 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -556,7 +556,6 @@ int QFontMetrics::width(const QString &text, int len, int flags) const } QStackTextEngine layout(text, QFont(d.data())); - layout.ignoreBidi = true; return qRound(layout.width(0, len)); } @@ -692,7 +691,6 @@ QRect QFontMetrics::boundingRect(const QString &text) const return QRect(); QStackTextEngine layout(text, QFont(d.data())); - layout.ignoreBidi = true; layout.itemize(); glyph_metrics_t gm = layout.boundingBox(0, text.length()); return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height)); @@ -861,7 +859,6 @@ QRect QFontMetrics::tightBoundingRect(const QString &text) const return QRect(); QStackTextEngine layout(text, QFont(d.data())); - layout.ignoreBidi = true; layout.itemize(); glyph_metrics_t gm = layout.tightBoundingBox(0, text.length()); return QRect(qRound(gm.x), qRound(gm.y), qRound(gm.width), qRound(gm.height)); @@ -1413,7 +1410,6 @@ qreal QFontMetricsF::width(const QString &text) const int len = (pos != -1) ? pos : text.length(); QStackTextEngine layout(text, QFont(d.data())); - layout.ignoreBidi = true; layout.itemize(); return layout.width(0, len).toReal(); } @@ -1496,7 +1492,6 @@ QRectF QFontMetricsF::boundingRect(const QString &text) const return QRectF(); QStackTextEngine layout(text, QFont(d.data())); - layout.ignoreBidi = true; layout.itemize(); glyph_metrics_t gm = layout.boundingBox(0, len); return QRectF(gm.x.toReal(), gm.y.toReal(), @@ -1668,7 +1663,6 @@ QRectF QFontMetricsF::tightBoundingRect(const QString &text) const return QRect(); QStackTextEngine layout(text, QFont(d.data())); - layout.ignoreBidi = true; layout.itemize(); glyph_metrics_t gm = layout.tightBoundingBox(0, text.length()); return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal()); -- cgit v1.2.3 From 33ebe6009872229ceca4171e7e6934f919affc1f Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Wed, 18 Jan 2017 10:54:19 +0100 Subject: PNG image handler: Avoid "invalid distance too far back" error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For certain slightly miscoded png images, newer versions of libpng will trigger the mentioned zlib error and fail to read the image. This miscoding has until now been safely ignored by all png implementations, so such images exist in the wild, and users expect them to work. Since the cost of the workaround is only a missed opportunity of a tiny saving in memory usage during decoding, enable it. Task-number: QTBUG-58171 Change-Id: I820a9faef6d5b7af79c04404ebdceb48a096f29a Reviewed-by: André Klitzing Reviewed-by: Allan Sandfeld Jensen --- src/gui/image/qpnghandler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index fdf77e162c..d55a26b2a4 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -521,6 +521,12 @@ bool QPngHandlerPrivate::readPngHeader() png_set_error_fn(png_ptr, 0, 0, qt_png_warning); +#if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW) + // Trade off a little bit of memory for better compatibility with existing images + // Ref. "invalid distance too far back" explanation in libpng-manual.txt + png_set_option(png_ptr, PNG_MAXIMUM_INFLATE_WINDOW, PNG_OPTION_ON); +#endif + info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { png_destroy_read_struct(&png_ptr, 0, 0); -- cgit v1.2.3 From bba4abd35fcfff294cda266ddd9e73d04c805860 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 10 Dec 2016 13:55:50 -0800 Subject: QXmlStream{Reader,Writer} don't need QtXml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit They're in QtCore. Change-Id: I63e21df51c7448bc8b5ffffd148f03c5e80b6fea Reviewed-by: Jędrzej Nowacki --- examples/xml/xmlstreamlint/xmlstreamlint.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/xml/xmlstreamlint/xmlstreamlint.pro b/examples/xml/xmlstreamlint/xmlstreamlint.pro index 97526693d0..cf03c4817a 100644 --- a/examples/xml/xmlstreamlint/xmlstreamlint.pro +++ b/examples/xml/xmlstreamlint/xmlstreamlint.pro @@ -1,7 +1,6 @@ CONFIG += console CONFIG -= app_bundle QT -= gui -QT += xml SOURCES += main.cpp # install -- cgit v1.2.3 From 9369eca108cc509ed651c0dbab6fa54de83727fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Klitzing?= Date: Tue, 3 Jan 2017 15:50:16 +0100 Subject: Update bundled libpng to version 1.6.28 Merged in the upstream version. The remaining diff to clean 1.6.28 is archived in the qtpatches.diff file. This fixes CVE-2016-10087 but Qt was never vulnerable to that issue! [ChangeLog][Third-Party Code] libpng was updated to version 1.6.28. Change-Id: I46712103fb160f31702eb7496fdd5c492a59ba5b Reviewed-by: Frederik Gladhorn Reviewed-by: Eirik Aavitsland --- src/3rdparty/libpng/ANNOUNCE | 45 +-- src/3rdparty/libpng/CHANGES | 354 ++++++++++++++++++++- src/3rdparty/libpng/INSTALL | 103 +++--- src/3rdparty/libpng/LICENSE | 35 ++- src/3rdparty/libpng/README | 5 +- src/3rdparty/libpng/libpng-manual.txt | 65 +++- src/3rdparty/libpng/png.c | 534 +++++++++++++++++--------------- src/3rdparty/libpng/png.h | 380 +++++++++++++++-------- src/3rdparty/libpng/pngconf.h | 50 +-- src/3rdparty/libpng/pngdebug.h | 2 +- src/3rdparty/libpng/pngerror.c | 70 ++--- src/3rdparty/libpng/pngget.c | 72 ++--- src/3rdparty/libpng/pnginfo.h | 2 +- src/3rdparty/libpng/pngmem.c | 22 +- src/3rdparty/libpng/pngpread.c | 46 +-- src/3rdparty/libpng/pngpriv.h | 275 ++++++++++------ src/3rdparty/libpng/pngread.c | 435 +++++++++++++++----------- src/3rdparty/libpng/pngrio.c | 6 +- src/3rdparty/libpng/pngrtran.c | 96 +++--- src/3rdparty/libpng/pngrutil.c | 327 +++++++++---------- src/3rdparty/libpng/pngset.c | 304 ++++++++++++------ src/3rdparty/libpng/pngstruct.h | 10 +- src/3rdparty/libpng/pngtrans.c | 15 +- src/3rdparty/libpng/pngwio.c | 6 +- src/3rdparty/libpng/pngwrite.c | 297 +++++++++++++----- src/3rdparty/libpng/pngwtran.c | 10 +- src/3rdparty/libpng/pngwutil.c | 328 +++++++++++--------- src/3rdparty/libpng/qt_attribution.json | 21 +- 28 files changed, 2494 insertions(+), 1421 deletions(-) diff --git a/src/3rdparty/libpng/ANNOUNCE b/src/3rdparty/libpng/ANNOUNCE index 4dae783b55..70a71e3b0e 100644 --- a/src/3rdparty/libpng/ANNOUNCE +++ b/src/3rdparty/libpng/ANNOUNCE @@ -1,4 +1,4 @@ -Libpng 1.6.20 - December 3, 2015 +Libpng 1.6.28 - January 5, 2017 This is a public release of libpng, intended for use in production codes. @@ -7,41 +7,28 @@ Files available for download: Source files with LF line endings (for Unix/Linux) and with a "configure" script - libpng-1.6.20.tar.xz (LZMA-compressed, recommended) - libpng-1.6.20.tar.gz + libpng-1.6.28.tar.xz (LZMA-compressed, recommended) + libpng-1.6.28.tar.gz Source files with CRLF line endings (for Windows), without the "configure" script - /scratch/glennrp/Libpng16/lpng1620.7z (LZMA-compressed, recommended) - /scratch/glennrp/Libpng16/lpng1620.zip + lpng1628.7z (LZMA-compressed, recommended) + lpng1628.zip Other information: - libpng-1.6.20-README.txt - libpng-1.6.20-LICENSE.txt - libpng-1.6.20-*.asc (armored detached GPG signatures) - -Changes since the last public release (1.6.19): - Avoid potential pointer overflow/underflow in png_handle_sPLT() and - png_handle_pCAL() (Bug report by John Regehr). - Fixed incorrect implementation of png_set_PLTE() that uses png_ptr - not info_ptr, that left png_set_PLTE() open to the CVE-2015-8126 - vulnerability. - Backported tests from libpng-1.7.0beta69. - Fixed an error in handling of bad zlib CMINFO field in pngfix, found by - American Fuzzy Lop, reported by Brian Carpenter. inflate() doesn't - immediately fault a bad CMINFO field; instead a 'too far back' error - happens later (at least some times). pngfix failed to limit CMINFO to - the allowed values but then assumed that window_bits was in range, - triggering an assert. The bug is mostly harmless; the PNG file cannot - be fixed. - In libpng 1.6 zlib initialization was changed to use the window size - in the zlib stream, not a fixed value. This causes some invalid images, - where CINFO is too large, to display 'correctly' if the rest of the - data is valid. This provides a workaround for zlib versions where the - error arises (ones that support the API change to use the window size - in the stream). + libpng-1.6.28-README.txt + libpng-1.6.28-LICENSE.txt + libpng-1.6.28-*.asc (armored detached GPG signatures) + +Changes since the last public release (1.6.27): + Fixed arm/aarch64 detection in CMakeLists.txt (Gianfranco Costamagna). + Added option to Cmake build allowing a custom location of zlib to be + specified in a scenario where libpng is being built as a subproject + alongside zlib by another project (Sam Serrels). + Changed png_ptr->options from a png_byte to png_uint_32, to accomodate + up to 16 options. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/src/3rdparty/libpng/CHANGES b/src/3rdparty/libpng/CHANGES index 28094fd26c..0b5e944ee3 100644 --- a/src/3rdparty/libpng/CHANGES +++ b/src/3rdparty/libpng/CHANGES @@ -593,7 +593,7 @@ Version 1.0.5e [November 30, 1999] with trailing compressed parts easier in the future, and added new functions png_free_iCCP, png_free_pCAL, png_free_sPLT, png_free_text, png_get_iCCP, png_get_spalettes, png_set_iCCP, png_set_spalettes (Eric S. Raymond). - NOTE: Applications that write text chunks MUST define png_text->lang + NOTE: Applications that write text chunks MUST define png_text->lang before calling png_set_text(). It must be set to NULL if you want to write tEXt or zTXt chunks. If you want your application to be able to run with older versions of libpng, use @@ -5063,7 +5063,8 @@ Version 1.6.15beta04 [November 4, 2014] Version 1.6.15beta05 [November 5, 2014] Use png_get_libpng_ver(NULL) instead of PNG_LIBPNG_VER_STRING in example.c, pngtest.c, and applications in the contrib directory. - Avoid out-of-bounds memory access in png_user_version_check(). + Fixed an out-of-range read in png_user_version_check() (Bug report from + Qixue Xiao, CVE-2015-8540). Simplified and future-proofed png_user_version_check(). Fixed GCC unsigned int->float warnings. Various versions of GCC seem to generate warnings when an unsigned value is implicitly @@ -5421,7 +5422,7 @@ Version 1.6.20beta01 [November 20, 2015] Version 1.6.20beta02 [November 23, 2015] Fixed incorrect implementation of png_set_PLTE() that uses png_ptr not info_ptr, that left png_set_PLTE() open to the CVE-2015-8126 - vulnerability. + vulnerability. Fixes CVE-2015-8472. Version 1.6.20beta03 [November 24, 2015] Backported tests from libpng-1.7.0beta69. @@ -5446,6 +5447,353 @@ Version 1.6.20rc02 [November 29, 2015] Version 1.6.20 [December 3, 2015] No changes. +Version 1.6.21beta01 [December 11, 2015] + Fixed syntax "$(command)" in tests/pngstest that some shells other than + bash could not parse (Bug report by Nelson Beebe). Use `command` instead. + +Version 1.6.21beta02 [December 14, 2015] + Moved png_check_keyword() from pngwutil.c to pngset.c + Removed LE/BE dependencies in pngvalid, to 'fix' the current problem + in the BigEndian tests by not testing it, making the BE code the same + as the LE version. + Fixes to pngvalid for various reduced build configurations (eliminate unused + statics) and a fix for the case in rgb_to_gray when the digitize option + reduces graylo to 0, producing a large error. + +Version 1.6.21beta03 [December 18, 2015] + Widened the 'limit' check on the internally calculated error limits in + the 'DIGITIZE' case (the code used prior to 1.7 for rgb_to_gray error + checks) and changed the check to only operate in non-release builds + (base build type not RC or RELEASE.) + Fixed undefined behavior in pngvalid.c, undefined because + (png_byte) << shift is undefined if it changes the signed bit + (because png_byte is promoted to int). The libpng exported functions + png_get_uint_32 and png_get_uint_16 handle this. (Bug reported by + David Drysdale as a result of reports from UBSAN in clang 3.8). + This changes pngvalid to use BE random numbers; this used to produce + errors but these should not be fixed as a result of the previous changes. + +Version 1.6.21rc01 [January 4, 2016] + In projects/vstudio, combined readme.txt and WARNING into README.txt + +Version 1.6.21rc02 [January 7, 2016] + Relocated assert() in contrib/tools/pngfix.c, bug found by American + Fuzzy Lop, reported by Brian Carpenter. + Marked 'limit' UNUSED in transform_range_check(). This only affects + release builds. + +Version 1.6.21 [January 15, 2016] + Worked around a false-positive Coverity issue in pngvalid.c. + +Version 1.6.22beta01 [January 23, 2016] + Changed PNG_USE_MKSTEMP to __COVERITY__ to select alternate + "tmpfile()" implementation in contrib/libtests/pngstest.c + Fixed NO_STDIO build of pngunknown.c to skip calling png_init_io() + if there is no stdio.h support. + Added a png_image_write_to_memory() API and a number of assist macros + to allow an application that uses the simplified API write to bypass + stdio and write directly to memory. + Added some warnings (png.h) and some check code to detect *possible* + overflow in the ROW_STRIDE and simplified image SIZE macros. This + disallows image width/height/format that *might* overflow. This is + a quiet API change that limits in-memory image size (uncompressed) to + less than 4GByte and image row size (stride) to less than 2GByte. + Revised workaround for false-positive Coverity issue in pngvalid.c. + +Version 1.6.22beta02 [February 8, 2016] + Only use exit(77) in configure builds. + Corrected error in PNG_IMAGE_PNG_SIZE_MAX. This new macro underreported + the palette size because it failed to take into account that the memory + palette has to be expanded to full RGB when it is written to PNG. + Updated CMakeLists.txt, added supporting scripts/gen*.cmake.in + and test.cmake.in (Roger Leigh). + Relaxed limit checks on gamma values in pngrtran.c. As suggested in + the comments gamma values outside the range currently permitted + by png_set_alpha_mode are useful for HDR data encoding. These values + are already permitted by png_set_gamma so it is reasonable caution to + extend the png_set_alpha_mode range as HDR imaging systems are starting + to emerge. + +Version 1.6.22beta03 [March 9, 2016] + Added a common-law trademark notice and export control information + to the LICENSE file, png.h, and the man page. + Restored "& 0xff" in png_save_uint_16() and png_save_uint_32() that + were accidentally removed from libpng-1.6.17. + Changed PNG_INFO_cHNK and PNG_FREE_cHNK from 0xnnnn to 0xnnnnU in png.h + (Robert C. Seacord). + Removed dubious "#if INT_MAX" test from png.h that was added to + libpng-1.6.19beta02 (John Bowler). + Add ${INCLUDES} in scripts/genout.cmake.in (Bug report by Nixon Kwok). + Updated LICENSE to say files in the contrib directory are not + necessarily under the libpng license, and that some makefiles have + other copyright owners. + Added INTEL-SSE2 support (Mike Klein and Matt Sarett, Google, Inc.). + Made contrib/libtests/timepng more robust. The code no longer gives + up/fails on invalid PNG data, it just skips it (with error messages). + The code no longer fails on PNG files with data beyond IEND. Options + exist to use png_read_png (reading the whole image, not by row) and, in + that case, to apply any of the supported transforms. This makes for + more realistic testing; the decoded data actually gets used in a + meaningful fashion (John Bowler). + Fixed some misleading indentation (Krishnaraj Bhat). + +Version 1.6.22beta04 [April 5, 2016] + Force GCC compilation to C89 if needed (Dagobert Michelsen). + SSE filter speed improvements for bpp=3: + memcpy-free implementations of load3() / store3(). + call load3() only when needed at the end of a scanline. + +Version 1.6.22beta05 [April 27, 2016] + Added PNG_FAST_FILTERS macro (defined as + PNG_FILTER_NONE|PNG_FILTER_SUB|PNG_FILTER_UP). + Various fixes for contrib/libtests/timepng.c + Moved INTEL-SSE code from pngpriv.h into contrib/intel/intel_sse.patch. + Fixed typo (missing underscore) in #define PNG_READ_16_TO_8_SUPPORTED + (Bug report by Y.Ohashik). + +Version 1.6.22beta06 [May 5, 2016] + Rebased contrib/intel_sse.patch. + Quieted two Coverity issues in contrib/libtests/timepng.c. + Fixed issues with scripts/genout.cmake.in (David Capello, Nixon Kwok): + Added support to use multiple directories in ZLIBINCDIR variable, + Fixed CMAKE_C_FLAGS with multiple values when genout is compiled on MSVC, + Fixed pnglibconf.c compilation on OS X including the sysroot path. + +Version 1.6.22rc01 [May 14, 2016] + No changes. + +Version 1.6.22rc02 [May 16, 2016] + Removed contrib/timepng from default build; it does not build on platforms + that don't supply clock_gettime(). + +Version 1.6.22rc03 [May 17, 2016] + Restored contrib/timepng to default build but check for the presence + of clock_gettime() in configure.ac and Makefile.am. + +Version 1.6.22 [May 26, 2016] + No changes. + +Version 1.6.23beta01 [May 29, 2016] + Stop a potential memory leak in png_set_tRNS() (Bug report by Ted Ying). + Fixed the progressive reader to handle empty first IDAT chunk properly + (patch by Timothy Nikkel). This bug was introduced in libpng-1.6.0 and + only affected the libpng16 branch. + Added tests in pngvalid.c to check zero-length IDAT chunks in various + positions. Fixed the sequential reader to handle these more robustly + (John Bowler). + +Version 1.6.23rc01 [June 2, 2016] + Corrected progressive read input buffer in pngvalid.c. The previous version + the code invariably passed just one byte at a time to libpng. The intent + was to pass a random number of bytes in the range 0..511. + Moved sse2 prototype from pngpriv.h to contrib/intel/intel_sse.patch. + Added missing ")" in pngerror.c (Matt Sarrett). + +Version 1.6.23rc02 [June 4, 2016] + Fixed undefined behavior in png_push_save_buffer(). Do not call + memcpy() with a null source, even if count is zero (Leon Scroggins III). + +Version 1.6.23 [June 9, 2016] + Fixed bad link to RFC2083 in png.5 (Nikola Forro). + +Version 1.6.24beta01 [June 11, 2016] + Avoid potential overflow of the PNG_IMAGE_SIZE macro. This macro + is not used within libpng, but is used in some of the examples. + +Version 1.6.24beta02 [June 23, 2016] + Correct filter heuristic overflow handling. This was broken when the + write filter code was moved out-of-line; if there is a single filter and + the heuristic sum overflows the calculation of the filtered line is not + completed. In versions prior to 1.6 the code was duplicated in-line + and the check not performed, so the filter operation completed; however, + in the multi-filter case where the sum is performed the 'none' filter would + be selected if all the sums overflowed, even if it wasn't in the filter + list. The fix to the first problem is simply to provide PNG_SIZE_MAX as + the current lmins sum value; this means the sum can never exceed it and + overflows silently. A reasonable compiler that does choose to inline + the code will simply eliminate the sum check. + The fix to the second problem is to use high precision arithmetic (this is + implemented in 1.7), however a simple safe fix here is to chose the lowest + numbered filter in the list from png_set_filter (this only works if the + first problem is also fixed) (John Bowler). + Use a more efficient absolute value calculation on SSE2 (Matthieu Darbois). + Fixed the case where PNG_IMAGE_BUFFER_SIZE can overflow in the application + as a result of the application using an increased 'row_stride'; previously + png_image_finish_read only checked for overflow on the base calculation of + components. (I.e. it checked for overflow of a 32-bit number on the total + number of pixel components in the output format, not the possibly padded row + length and not the number of bytes, which for linear formats is twice the + number of components.) + MSVC does not like '-(unsigned)', so replaced it with 0U-(unsigned) + MSVC does not like (uInt) = -(unsigned) (i.e. as an initializer), unless + the conversion is explicitly invoked by a cast. + Put the SKIP definition in the correct place. It needs to come after the + png.h include (see all the other .c files in contrib/libtests) because it + depends on PNG_LIBPNG_VER. + Removed the three compile warning options from the individual project + files into the zlib.props globals. It increases the warning level from 4 + to All and adds a list of the warnings that need to be turned off. This is + semi-documentary; the intent is to tell libpng users which warnings have + been examined and judged non-fixable at present. The warning about + structure padding is fixable, but it would be a signficant change (moving + structure members around). + +Version 1.6.24beta03 [July 4, 2016] + Optimized absolute value calculation in filter selection, similar to + code in the PAETH decoder in pngrutil.c. Build with PNG_USE_ABS to + use this. + Added pngcp to the build together with a pngcp.dfa configuration test. + Added high resolution timing to pngcp. + Added "Common linking failures" section to INSTALL. + Relocated misplaced #endif in png.c sRGB profile checking. + Fixed two Coverity issues in pngcp.c. + +Version 1.6.24beta04 [July 8, 2016] + Avoid filter-selection heuristic sum calculations in cases where only one + filter is a candidate for selection. This trades off code size (added + private png_setup_*_row_only() functions) for speed. + +Version 1.6.24beta05 [July 13, 2016] + Fixed some indentation to comply with our coding style. + Added contrib/tools/reindent. + +Version 1.6.24beta06 [July 18, 2016] + Fixed more indentation to comply with our coding style. + Eliminated unnecessary tests of boolean png_isaligned() vs 0. + +Version 1.6.24rc01 [July 25, 2016] + No changes. + +Version 1.6.24rc02 [August 1, 2016] + Conditionally compile SSE2 headers in contrib/intel/intel_sse.patch + Conditionally compile png_decompress_chunk(). + +Version 1.6.24rc03 [August 2, 2016] + Conditionally compile ARM_NEON headers in pngpriv.h + Updated contrib/intel/intel_sse.patch + +Version 1.6.24[August 4, 2016] + No changes. + +Version 1.6.25beta01 [August 12, 2016] + Reject oversized iCCP profile immediately. + Cleaned up PNG_DEBUG compile of pngtest.c. + Conditionally compile png_inflate(). + +Version 1.6.25beta02 [August 18, 2016] + Don't install pngcp; it conflicts with pngcp in the pngtools package. + Minor editing of INSTALL, (whitespace, added copyright line) + +Version 1.6.25rc01 [August 24, 2016] + No changes. + +Version 1.6.25rc02 [August 29, 2016] + Added MIPS support (Mandar Sahastrabuddhe ). + Only the UP filter is currently implemented. + +Version 1.6.25rc03 [August 29, 2016] + Rebased contrib/intel/intel_sse.patch after the MIPS implementation. + +Version 1.6.25rc04 [August 30, 2016] + Added MIPS support for SUB, AVG, and PAETH filters (Mandar Sahastrabuddhe). + +Version 1.6.25rc05 [August 30, 2016] + Rebased contrib/intel/intel_sse.patch after the MIPS implementation update.. + +Version 1.6.25 [September 1, 2016] + No changes. + +Version 1.6.26beta01 [September 26, 2016] + Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo, + bugfix by John Bowler). + Do not issue a png_error() on read in png_set_pCAL() because png_handle_pCAL + has allocated memory that libpng needs to free. + Conditionally compile png_set_benign_errors() in pngread.c and pngtest.c + Issue a png_benign_error instead of a png_error on ADLER32 mismatch + while decoding compressed data chunks. + Changed PNG_ZLIB_VERNUM to ZLIB_VERNUM in pngpriv.h, pngstruct.h, and + pngrutil.c. + If CRC handling of critical chunks has been set to PNG_CRC_QUIET_USE, + ignore the ADLER32 checksum in the IDAT chunk as well as the chunk CRCs. + Issue png_benign_error() on ADLER32 checksum mismatch instead of png_error(). + Add tests/badcrc.png and tests/badadler.png to tests/pngtest. + Merged pngtest.c with libpng-1.7.0beta84/pngtest.c + +Version 1.6.26beta02 [October 1, 2016] + Updated the documentation about CRC and ADLER32 handling. + Quieted 117 warnings from clang-3.8 in pngtrans.c, pngread.c, + pngwrite.c, pngunknown.c, and pngvalid.c. + Quieted 58 (out of 144) -Wconversion compiler warnings by changing + flag definitions in pngpriv.h from 0xnnnn to 0xnnnnU and trivial changes + in png.c, pngread.c, and pngwutil.c. + +Version 1.6.26beta03 [October 2, 2016] + Removed contrib/libtests/*.orig and *.rej that slipped into the tarballs. + Quieted the 86 remaining -Wconversion compiler warnings by + revising the png_isaligned() macro and trivial changes in png.c, + pngerror.c, pngget.c, pngmem.c, pngset.c, pngrtran.c, pngrutil.c, + pngwtran.c, pngwrite.c, and pngwutil.c. + +Version 1.6.26beta04 [October 3, 2016] + Quieted (bogus?) clang warnings about "absolute value has no effect" + when PNG_USE_ABS is defined. + Fixed offsets in contrib/intel/intel_sse.patch + +Version 1.6.26beta05 [October 6, 2016] + Changed integer constant 4294967294 to unsigned 4294967294U in pngconf.h + to avoid a signed/unsigned compare in the preprocessor. + +Version 1.6.26beta06 [October 7, 2016] + Use zlib-1.2.8.1 inflateValidate() instead of inflateReset2() to + optionally avoid ADLER32 evaluation. + +Version 1.6.26rc01 [October 12, 2016] + No changes. + +Version 1.6.26 [October 20, 2016] + Cosmetic change, "ptr != 0" to "ptr != NULL" in png.c and pngrutil.c + Despammed email addresses (replaced "@" with " at "). + +Version 1.6.27beta01 [November 2, 2016] + Restrict the new ADLER32-skipping to IDAT chunks. It broke iCCP chunk + handling: an erroneous iCCP chunk would throw a png_error and reject the + entire PNG image instead of rejecting just the iCCP chunk with a warning, + if built with zlib-1.2.8.1. + +Version 1.6.27rc01 [December 27, 2016] + Control ADLER32 checking with new PNG_IGNORE_ADLER32 option. + Removed the use of a macro containing the pre-processor 'defined' + operator. It is unclear whether this is valid; a macro that + "generates" 'defined' is not permitted, but the use of the word + "generates" within the C90 standard seems to imply more than simple + substitution of an expression itself containing a well-formed defined + operation. + Added ARM support to CMakeLists.txt (Andreas Franek). + +Version 1.6.27 [December 29, 2016] + Fixed a potential null pointer dereference in png_set_text_2() (bug report + and patch by Patrick Keshishian, CVE-2016-10087). + +Version 1.6.28rc01 [January 3, 2017] + Fixed arm/aarch64 detection in CMakeLists.txt (Gianfranco Costamagna). + Added option to Cmake build allowing a custom location of zlib to be + specified in a scenario where libpng is being built as a subproject + alongside zlib by another project (Sam Serrels). + Changed png_ptr->options from a png_byte to png_uint_32, to accomodate + up to 16 options. + +Version 1.6.28rc02 [January 4, 2017] + Added "include(GNUInstallDirs)" to CMakeLists.txt (Gianfranco Costamagna). + Moved SSE2 optimization code into the main libpng source directory. + Configure libpng with "configure --enable-intel-sse" or compile + libpng with "-DPNG_INTEL_SSE" in CPPFLAGS to enable it. + +Version 1.6.28rc03 [January 4, 2017] + Backed out the SSE optimization and last CMakeLists.txt to allow time for QA. + +Version 1.6.28 [January 5, 2017] + No changes. + Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement diff --git a/src/3rdparty/libpng/INSTALL b/src/3rdparty/libpng/INSTALL index 531652abe0..58ec0b60a7 100644 --- a/src/3rdparty/libpng/INSTALL +++ b/src/3rdparty/libpng/INSTALL @@ -1,24 +1,25 @@ -Installing libpng + Installing libpng Contents - I. Simple installation - II. Rebuilding the configure scripts - III. Using scripts/makefile* - IV. Using cmake - V. Directory structure - VI. Building with project files - VII. Building with makefiles -VIII. Configuring libpng for 16-bit platforms - IX. Configuring for DOS - X. Configuring for Medium Model - XI. Prepending a prefix to exported symbols - XII. Configuring for compiler xxx: -XIII. Removing unwanted object code - XIV. Changes to the build and configuration of libpng in libpng-1.5.x - XV. Setjmp/longjmp issues - XVI. Other sources of information about libpng + I. Simple installation + II. Rebuilding the configure scripts + III. Using scripts/makefile* + IV. Using cmake + V. Directory structure + VI. Building with project files + VII. Building with makefiles + VIII. Configuring libpng for 16-bit platforms + IX. Configuring for DOS + X. Configuring for Medium Model + XI. Prepending a prefix to exported symbols + XII. Configuring for compiler xxx: + XIII. Removing unwanted object code + XIV. Changes to the build and configuration of libpng in libpng-1.5.x + XV. Setjmp/longjmp issues + XVI. Common linking failures + XVII. Other sources of information about libpng I. Simple installation @@ -47,7 +48,9 @@ If configure does not work on your system, or if you have a need to change configure.ac or Makefile.am, and you have a reasonably up-to-date set of tools, running ./autogen.sh in a git clone before running ./configure may fix the problem. To be really sure that you -aren't using any of the included pre-built scripts, you can do this: +aren't using any of the included pre-built scripts, especially if you +are building from a tar distribution instead of a git distribution, +do this: ./configure --enable-maintainer-mode make maintainer-clean @@ -76,7 +79,7 @@ Or you can use one of the "projects" in the "projects" directory. Before installing libpng, you must first install zlib, if it is not already on your system. zlib can usually be found wherever you got libpng; otherwise go to http://zlib.net. You can place -zlib in in the same directory as libpng or in another directory. +zlib in the same directory as libpng or in another directory. If your system already has a preinstalled zlib you will still need to have access to the zlib.h and zconf.h include files that @@ -87,22 +90,24 @@ standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS, and LD_LIBRARY_PATH in your environment before running "make test" or "make distcheck": -ZLIBLIB=/path/to/lib export ZLIBLIB -ZLIBINC=/path/to/include export ZLIBINC -CPPFLAGS="-I$ZLIBINC" export CPPFLAGS -LDFLAGS="-L$ZLIBLIB" export LDFLAGS -LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH + ZLIBLIB=/path/to/lib export ZLIBLIB + ZLIBINC=/path/to/include export ZLIBINC + CPPFLAGS="-I$ZLIBINC" export CPPFLAGS + LDFLAGS="-L$ZLIBLIB" export LDFLAGS + LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC -in your environment and type "make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test". +in your environment and type + + make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test IV. Using cmake If you want to use "cmake" (see www.cmake.org), type - cmake . -DCMAKE_INSTALL_PREFIX=/path - make - make install + cmake . -DCMAKE_INSTALL_PREFIX=/path + make + make install As when using the simple configure method described above, "/path" points to the installation directory where you want to put the libpng "lib", "include", @@ -116,8 +121,8 @@ or "zlib128") so that you have directories called "zlib" and "libpng". Your directory structure should look like this: - .. (the parent directory) - libpng (this directory) + .. (the parent directory) + libpng (this directory) INSTALL (this file) README *.h, *.c => libpng source files @@ -160,10 +165,15 @@ VII. Building with makefiles Copy the file (or files) that you need from the scripts directory into this directory, for example - MSDOS example: copy scripts\makefile.msc makefile - copy scripts\pnglibconf.h.prebuilt pnglibconf.h - UNIX example: cp scripts/makefile.std makefile - cp scripts/pnglibconf.h.prebuilt pnglibconf.h +MSDOS example: + + copy scripts\makefile.msc makefile + copy scripts\pnglibconf.h.prebuilt pnglibconf.h + +UNIX example: + + cp scripts/makefile.std makefile + cp scripts/pnglibconf.h.prebuilt pnglibconf.h Read the makefile to see if you need to change any source or target directories to match your preferences. @@ -239,7 +249,7 @@ libpng are compiled. All the defines end in _SUPPORTED. If you are never going to use a capability, you can change the #define to #undef before recompiling libpng and save yourself code and data space, or you can turn off individual capabilities with defines that begin with -PNG_NO_. +"PNG_NO_". In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead. @@ -307,7 +317,7 @@ only png_longjmp_ptr, which must match the C longjmp function.) The new approach is documented in pngconf.h Despite these changes, libpng 1.5.0 only supports the native C function -calling standard on those platforms tested so far (__cdecl on Microsoft +calling standard on those platforms tested so far ("__cdecl" on Microsoft Windows). This is because the support requirements for alternative calling conventions seem to no longer exist. Developers who find it necessary to set PNG_API_RULE to 1 should advise the mailing list @@ -371,7 +381,7 @@ your application is going to be using multiple threads, you should configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with -DPNG_NO_SETJMP on your compile line, or with - #undef PNG_SETJMP_SUPPORTED + #undef PNG_SETJMP_SUPPORTED in your pnglibconf.h or pngusr.h. @@ -380,8 +390,25 @@ This requires setjmp/longjmp, so you must either build the library with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined. -XVI. Other sources of information about libpng: +XVI. Common linking failures + +If your application fails to find libpng or zlib entries while linking: + + Be sure "-lz" appears after "-lpng" on your linking command. + + Be sure you have built libpng, zlib, and your application for the + same platform (e.g., 32-bit or 64-bit). + + If you are using the vstudio project, observe the WARNING in + project/vstudio/README.txt. + +XVII. Other sources of information about libpng: Further information can be found in the README and libpng-manual.txt files, in the individual makefiles, in png.h, and the manual pages libpng.3 and png.5. + +Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson +This document is released under the libpng license. +For conditions of distribution and use, see the disclaimer +and license in png.h. diff --git a/src/3rdparty/libpng/LICENSE b/src/3rdparty/libpng/LICENSE index 82dbe117f6..912552e2af 100644 --- a/src/3rdparty/libpng/LICENSE +++ b/src/3rdparty/libpng/LICENSE @@ -10,8 +10,8 @@ this sentence. This code is released under the libpng license. -libpng versions 1.0.7, July 1, 2000, through 1.6.20, December 3, 2015, are -Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are +libpng versions 1.0.7, July 1, 2000 through 1.6.28, January 5, 2017 are +Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are derived from libpng-1.0.6, and are distributed according to the same disclaimer and license as libpng-1.0.6 with the following individuals added to the list of Contributing Authors: @@ -22,6 +22,7 @@ added to the list of Contributing Authors: Cosmin Truta Gilles Vollant James Yu + Mandar Sahastrabuddhe and with the following additions to the disclaimer: @@ -32,6 +33,10 @@ and with the following additions to the disclaimer: risk of satisfactory quality, performance, accuracy, and effort is with the user. +Some files in the "contrib" directory and some configure-generated +files that are distributed with libpng have other copyright owners and +are released under other open source licenses. + libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from libpng-0.96, and are distributed according to the same disclaimer and @@ -55,6 +60,9 @@ Contributing Authors: Greg Roelofs Tom Tanner +Some files in the "scripts" directory have other copyright owners +but are released under this license. + libpng versions 0.5, May 1995, through 0.88, January 1996, are Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. @@ -95,18 +103,29 @@ appreciated. END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE. -A "png_get_copyright" function is available, for convenient use in "about" -boxes and the like: +TRADEMARK: - printf("%s", png_get_copyright(NULL)); +The name "libpng" has not been registered by the Copyright owner +as a trademark in any jurisdiction. However, because libpng has +been distributed and maintained world-wide, continually since 1995, +the Copyright owner claims "common-law trademark protection" in any +jurisdiction where common-law trademark is recognized. -Also, the PNG logo (in PNG format, of course) is supplied in the -files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). +OSI CERTIFICATION: Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a certification mark of the Open Source Initiative. OSI has not addressed the additional disclaimers inserted at version 1.0.7. +EXPORT CONTROL: + +The Copyright owner believes that the Export Control Classification +Number (ECCN) for libpng is EAR99, which means not subject to export +controls or International Traffic in Arms Regulations (ITAR) because +it is open source, publicly available software, that does not contain +any encryption software. See the EAR, paragraphs 734.3(b)(3) and +734.7(b). + Glenn Randers-Pehrson glennrp at users.sourceforge.net -December 3, 2015 +January 5, 2017 diff --git a/src/3rdparty/libpng/README b/src/3rdparty/libpng/README index 59f1f918ae..67b579d13c 100644 --- a/src/3rdparty/libpng/README +++ b/src/3rdparty/libpng/README @@ -1,4 +1,4 @@ -README for libpng version 1.6.20 - December 3, 2015 (shared library 16.0) +README for libpng version 1.6.28 - January 5, 2017 (shared library 16.0) See the note about version numbers near the top of png.h See INSTALL for instructions on how to install libpng. @@ -180,15 +180,18 @@ Files in this distribution: pngwutil.c => Write utility functions arm => Contains optimized code for the ARM platform contrib => Contributions + arm-neon => Optimized code for ARM-NEON platform examples => Example programs gregbook => source code for PNG reading and writing, from Greg Roelofs' "PNG: The Definitive Guide", O'Reilly, 1999 + intel => Optimized code for INTEL-SSE2 platform libtests => Test programs pngminim => Minimal decoder, encoder, and progressive decoder programs demonstrating use of pngusr.dfa pngminus => Simple pnm2png and png2pnm programs pngsuite => Test images + testpngs tools => Various tools visupng => Contains a MSVC workspace for VisualPng projects => Contains project files and workspaces for diff --git a/src/3rdparty/libpng/libpng-manual.txt b/src/3rdparty/libpng/libpng-manual.txt index 87eeb2b583..048ba31c06 100644 --- a/src/3rdparty/libpng/libpng-manual.txt +++ b/src/3rdparty/libpng/libpng-manual.txt @@ -1,9 +1,9 @@ libpng-manual.txt - A description on how to use and modify libpng - libpng version 1.6.20 - December 3, 2015 + libpng version 1.6.28 - January 5, 2017 Updated and distributed by Glenn Randers-Pehrson - Copyright (c) 1998-2015 Glenn Randers-Pehrson + Copyright (c) 1998-2016 Glenn Randers-Pehrson This document is released under the libpng license. For conditions of distribution and use, see the disclaimer @@ -11,9 +11,9 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.6.20 - December 3, 2015 + libpng versions 0.97, January 1998, through 1.6.28 - January 5, 2017 Updated and distributed by Glenn Randers-Pehrson - Copyright (c) 1998-2015 Glenn Randers-Pehrson + Copyright (c) 1998-2016 Glenn Randers-Pehrson libpng 1.0 beta 6 - version 0.96 - May 28, 1997 Updated and distributed by Andreas Dilger @@ -467,8 +467,9 @@ the default, use The values for png_set_crc_action() say how libpng is to handle CRC errors in ancillary and critical chunks, and whether to use the data contained -therein. Note that it is impossible to "discard" data in a critical -chunk. +therein. Starting with libpng-1.6.26, this also governs how an ADLER32 error +is handled while reading the IDAT chunk. Note that it is impossible to +"discard" data in a critical chunk. Choices for (int) crit_action are PNG_CRC_DEFAULT 0 error/quit @@ -485,6 +486,9 @@ Choices for (int) ancil_action are PNG_CRC_QUIET_USE 4 quiet/use data PNG_CRC_NO_CHANGE 5 use the current value +When the setting for crit_action is PNG_CRC_QUIET_USE, the CRC and ADLER32 +checksums are not only ignored, but they are not evaluated. + Setting up callback code You can set up a callback function to handle any unknown chunks in the @@ -559,7 +563,7 @@ non-interlaced case the row that was just handled is simply one less than the passed in row number, and pass will always be 0. For the interlaced case the same applies unless the row value is 0, in which case the row just handled was the last one from one of the preceding passes. Because interlacing may skip a -pass you cannot be sure that the preceding pass is just 'pass-1', if you really +pass you cannot be sure that the preceding pass is just 'pass-1'; if you really need to know what the last pass is record (row,pass) from the callback and use the last recorded value each time. @@ -2230,7 +2234,8 @@ is exactly the same. If you are planning on displaying the image after each pass, the "rectangle" effect is generally considered the better looking one. -If you only want the "sparkle" effect, just call png_read_rows() as +If you only want the "sparkle" effect, just call png_read_row() or +png_read_rows() as normal, with the third parameter NULL. Make sure you make pass over the image number_of_passes times, and you don't change the data in the rows between calls. You can change the locations of the data, just @@ -2239,6 +2244,8 @@ pass, and assumes the data from previous passes is still valid. png_read_rows(png_ptr, row_pointers, NULL, number_of_rows); + or + png_read_row(png_ptr, row_pointers, NULL); If you only want the first effect (the rectangles), do the same as before except pass the row buffer in the third parameter, and leave @@ -2246,6 +2253,8 @@ the second parameter NULL. png_read_rows(png_ptr, NULL, row_pointers, number_of_rows); + or + png_read_row(png_ptr, NULL, row_pointers); If you don't want libpng to handle the interlacing details, just call png_read_rows() PNG_INTERLACE_ADAM7_PASSES times to read in all the images. @@ -2842,7 +2851,7 @@ filter types. PNG_FILTER_UP | PNG_FILTER_VALUE_UP | PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG | PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| - PNG_ALL_FILTERS); + PNG_ALL_FILTERS | PNG_FAST_FILTERS); If an application wants to start and stop using particular filters during compression, it should start out with all of the filters (to ensure that @@ -4103,6 +4112,13 @@ be written: Write the image to the named file. + int png_image_write_to_memory (png_imagep image, void *memory, + png_alloc_size_t * PNG_RESTRICT memory_bytes, + int convert_to_8_bit, const void *buffer, ptrdiff_t row_stride, + const void *colormap)); + + Write the image to memory. + int png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8_bit, const void *buffer, png_int_32 row_stride, const void *colormap) @@ -4380,8 +4396,9 @@ for any images with bit depths less than 8 bits/pixel. The 'method' parameter sets the main filtering method, which is currently only '0' in the PNG 1.2 specification. The 'filters' parameter sets which filter(s), if any, should be used for each -scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS -to turn filtering on and off, respectively. +scanline. Possible values are PNG_ALL_FILTERS, PNG_NO_FILTERS, +or PNG_FAST_FILTERS to turn filtering on and off, or to turn on +just the fast-decoding subset of filters, respectively. Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise @@ -4395,12 +4412,19 @@ means the first row must always be adaptively filtered, because libpng currently does not allocate the filter buffers until png_write_row() is called for the first time.) - filters = PNG_FILTER_NONE | PNG_FILTER_SUB + filters = PNG_NO_FILTERS; + filters = PNG_ALL_FILTERS; + filters = PNG_FAST_FILTERS; + + or + + filters = PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | PNG_FILTER_AVG | - PNG_FILTER_PAETH | PNG_ALL_FILTERS; + PNG_FILTER_PAETH; png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, filters); + The second parameter can also be PNG_INTRAPIXEL_DIFFERENCING if you are writing a PNG to be embedded in a MNG @@ -4775,7 +4799,8 @@ There are no substantial API changes between the non-deprecated parts of the 1.4.5 API and the 1.5.0 API; however, the ability to directly access members of the main libpng control structures, png_struct and png_info, deprecated in earlier versions of libpng, has been completely removed from -libpng 1.5. +libpng 1.5, and new private "pngstruct.h", "pnginfo.h", and "pngdebug.h" +header files were created. We no longer include zlib.h in png.h. The include statement has been moved to pngstruct.h, where it is not accessible by applications. Applications that @@ -5015,6 +5040,7 @@ includes the following: png_image_free() write functions png_image_write_to_file() + png_image_write_to_memory() png_image_write_to_stdio() Starting with libpng-1.6.0, you can configure libpng to prefix all exported @@ -5078,6 +5104,10 @@ enforced. The sRGB chunk is allowed to appear in images with any color type and is interpreted by libpng to convey a one-tracer-curve gray profile or a three-tracer-curve RGB profile as appropriate. +Libpng 1.5.x erroneously used /MD for Debug DLL builds; if you used the debug +builds in your app and you changed your app to use /MD you will need to +change it back to /MDd for libpng 1.6.x. + Prior to libpng-1.6.0 a warning would be issued if the iTXt chunk contained an empty language field or an empty translated keyword. Both of these are allowed by the PNG specification, so these warnings are no longer issued. @@ -5309,8 +5339,9 @@ with an even number of lower-case hex digits, and to make them unsigned We prefer to use underscores rather than camelCase in names, except for a few type names that we inherit from zlib.h. -We prefer "if (something != 0)" and "if (something == 0)" -over "if (something)" and if "(!something)", respectively. +We prefer "if (something != 0)" and "if (something == 0)" over +"if (something)" and if "(!something)", respectively, and for pointers +we prefer "if (some_pointer != NULL)" or "if (some_pointer == NULL)". We do not use the TAB character for indentation in the C sources. @@ -5324,7 +5355,7 @@ Since the PNG Development group is an ad-hoc body, we can't make an official declaration. This is your unofficial assurance that libpng from version 0.71 and -upward through 1.6.20 are Y2K compliant. It is my belief that earlier +upward through 1.6.28 are Y2K compliant. It is my belief that earlier versions were also Y2K compliant. Libpng only has two year fields. One is a 2-byte unsigned integer diff --git a/src/3rdparty/libpng/png.c b/src/3rdparty/libpng/png.c index c183e3f8fa..78ce39f46d 100644 --- a/src/3rdparty/libpng/png.c +++ b/src/3rdparty/libpng/png.c @@ -1,8 +1,8 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.6.19 [November 12, 2015] - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.28 [January 5, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -14,7 +14,7 @@ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef png_libpng_version_1_6_20 Your_png_h_is_not_version_1_6_20; +typedef png_libpng_version_1_6_28 Your_png_h_is_not_version_1_6_28; /* Tells libpng that we have already handled the first "num_bytes" bytes * of the PNG file signature. If the PNG data is embedded into another @@ -85,7 +85,7 @@ png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED) if (items >= (~(png_alloc_size_t)0)/size) { png_warning (png_voidcast(png_structrp, png_ptr), - "Potential overflow in png_zalloc()"); + "Potential overflow in png_zalloc()"); return NULL; } @@ -172,10 +172,10 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length) int png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver) { - /* Libpng versions 1.0.0 and later are binary compatible if the version - * string matches through the second '.'; we must recompile any - * applications that use any older library version. - */ + /* Libpng versions 1.0.0 and later are binary compatible if the version + * string matches through the second '.'; we must recompile any + * applications that use any older library version. + */ if (user_png_ver != NULL) { @@ -297,7 +297,7 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr, if (png_user_version_check(&create_struct, user_png_ver) != 0) { png_structrp png_ptr = png_voidcast(png_structrp, - png_malloc_warn(&create_struct, (sizeof *png_ptr))); + png_malloc_warn(&create_struct, (sizeof *png_ptr))); if (png_ptr != NULL) { @@ -346,7 +346,7 @@ png_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED) * has always been done in 'example.c'. */ info_ptr = png_voidcast(png_inforp, png_malloc_base(png_ptr, - (sizeof *info_ptr))); + (sizeof *info_ptr))); if (info_ptr != NULL) memset(info_ptr, 0, (sizeof *info_ptr)); @@ -402,7 +402,7 @@ png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr) */ PNG_FUNCTION(void,PNGAPI png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size), - PNG_DEPRECATED) + PNG_DEPRECATED) { png_inforp info_ptr = *ptr_ptr; @@ -417,7 +417,7 @@ png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size), /* The following line is why this API should not be used: */ free(info_ptr); info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL, - (sizeof *info_ptr))); + (sizeof *info_ptr))); if (info_ptr == NULL) return; *ptr_ptr = info_ptr; @@ -430,7 +430,7 @@ png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size), /* The following API is not called internally */ void PNGAPI png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr, - int freer, png_uint_32 mask) + int freer, png_uint_32 mask) { png_debug(1, "in png_data_freer"); @@ -449,7 +449,7 @@ png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr, void PNGAPI png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, - int num) + int num) { png_debug(1, "in png_free_data"); @@ -458,7 +458,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #ifdef PNG_TEXT_SUPPORTED /* Free text item num or (if num == -1) all text items */ - if (info_ptr->text != 0 && + if (info_ptr->text != NULL && ((mask & PNG_FREE_TEXT) & info_ptr->free_me) != 0) { if (num != -1) @@ -477,6 +477,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, png_free(png_ptr, info_ptr->text); info_ptr->text = NULL; info_ptr->num_text = 0; + info_ptr->max_text = 0; } } #endif @@ -541,7 +542,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #ifdef PNG_sPLT_SUPPORTED /* Free a given sPLT entry, or (if num == -1) all sPLT entries */ - if (info_ptr->splt_palettes != 0 && + if (info_ptr->splt_palettes != NULL && ((mask & PNG_FREE_SPLT) & info_ptr->free_me) != 0) { if (num != -1) @@ -571,7 +572,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, #endif #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED - if (info_ptr->unknown_chunks != 0 && + if (info_ptr->unknown_chunks != NULL && ((mask & PNG_FREE_UNKN) & info_ptr->free_me) != 0) { if (num != -1) @@ -617,7 +618,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, /* Free any image bits attached to the info structure */ if (((mask & PNG_FREE_ROWS) & info_ptr->free_me) != 0) { - if (info_ptr->row_pointers != 0) + if (info_ptr->row_pointers != NULL) { png_uint_32 row; for (row = 0; row < info_ptr->height; row++) @@ -684,7 +685,7 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp) void PNGAPI png_save_int_32(png_bytep buf, png_int_32 i) { - png_save_uint_32(buf, i); + png_save_uint_32(buf, (png_uint_32)i); } # endif @@ -775,14 +776,15 @@ png_get_copyright(png_const_structrp png_ptr) #else # ifdef __STDC__ return PNG_STRING_NEWLINE \ - "libpng version 1.6.20 - December 3, 2015" PNG_STRING_NEWLINE \ - "Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ + "libpng version 1.6.28 - January 5, 2017" PNG_STRING_NEWLINE \ + "Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \ + PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ PNG_STRING_NEWLINE; # else - return "libpng version 1.6.20 - December 3, 2015\ - Copyright (c) 1998-2015 Glenn Randers-Pehrson\ + return "libpng version 1.6.28 - January 5, 2017\ + Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; # endif @@ -1032,7 +1034,7 @@ png_zstream_error(png_structrp png_ptr, int ret) #ifdef PNG_GAMMA_SUPPORTED /* always set if COLORSPACE */ static int png_colorspace_check_gamma(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_fixed_point gAMA, int from) + png_colorspacerp colorspace, png_fixed_point gAMA, int from) /* This is called to check a new gamma value against an existing one. The * routine returns false if the new gamma value should not be written. * @@ -1046,7 +1048,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr, png_fixed_point gtest; if ((colorspace->flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && - (png_muldiv(>est, colorspace->gamma, PNG_FP_1, gAMA) == 0 || + (png_muldiv(>est, colorspace->gamma, PNG_FP_1, gAMA) == 0 || png_gamma_significant(gtest) != 0)) { /* Either this is an sRGB image, in which case the calculated gamma @@ -1058,7 +1060,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr, if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0 || from == 2) { png_chunk_report(png_ptr, "gamma value does not match sRGB", - PNG_CHUNK_ERROR); + PNG_CHUNK_ERROR); /* Do not overwrite an sRGB value */ return from == 2; } @@ -1066,7 +1068,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr, else /* sRGB tag not involved */ { png_chunk_report(png_ptr, "gamma value does not match libpng estimate", - PNG_CHUNK_WARNING); + PNG_CHUNK_WARNING); return from == 1; } } @@ -1076,7 +1078,7 @@ png_colorspace_check_gamma(png_const_structrp png_ptr, void /* PRIVATE */ png_colorspace_set_gamma(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_fixed_point gAMA) + png_colorspacerp colorspace, png_fixed_point gAMA) { /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't * occur. Since the fixed point representation is asymetrical it is @@ -1634,8 +1636,8 @@ static const png_xy sRGB_xy = /* From ITU-R BT.709-3 */ static int png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr, - png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ, - int preferred) + png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ, + int preferred) { if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0) return 0; @@ -1682,7 +1684,7 @@ png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr, int /* PRIVATE */ png_colorspace_set_chromaticities(png_const_structrp png_ptr, - png_colorspacerp colorspace, const png_xy *xy, int preferred) + png_colorspacerp colorspace, const png_xy *xy, int preferred) { /* We must check the end points to ensure they are reasonable - in the past * color management systems have crashed as a result of getting bogus @@ -1696,7 +1698,7 @@ png_colorspace_set_chromaticities(png_const_structrp png_ptr, { case 0: /* success */ return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, xy, &XYZ, - preferred); + preferred); case 1: /* We can't invert the chromaticities so we can't produce value XYZ @@ -1719,7 +1721,7 @@ png_colorspace_set_chromaticities(png_const_structrp png_ptr, int /* PRIVATE */ png_colorspace_set_endpoints(png_const_structrp png_ptr, - png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred) + png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred) { png_XYZ XYZ = *XYZ_in; png_xy xy; @@ -1728,7 +1730,7 @@ png_colorspace_set_endpoints(png_const_structrp png_ptr, { case 0: return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, &xy, &XYZ, - preferred); + preferred); case 1: /* End points are invalid. */ @@ -1785,7 +1787,7 @@ is_ICC_signature(png_alloc_size_t it) static int png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_alloc_size_t value, png_const_charp reason) + png_const_charp name, png_alloc_size_t value, png_const_charp reason) { size_t pos; char message[196]; /* see below for calculation */ @@ -1810,8 +1812,8 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114*/ pos = png_safecat(message, (sizeof message), pos, - png_format_number(number, number+(sizeof number), - PNG_NUMBER_FORMAT_x, value)); + png_format_number(number, number+(sizeof number), + PNG_NUMBER_FORMAT_x, value)); pos = png_safecat(message, (sizeof message), pos, "h: "); /*+2 = 116*/ } # endif @@ -1825,7 +1827,7 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, * application errors the PNG won't be written.) */ png_chunk_report(png_ptr, message, - (colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR); + (colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR); return 0; } @@ -1834,7 +1836,7 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace, #ifdef PNG_sRGB_SUPPORTED int /* PRIVATE */ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, - int intent) + int intent) { /* sRGB sets known gamma, end points and (from the chunk) intent. */ /* IMPORTANT: these are not necessarily the values found in an ICC profile @@ -1871,10 +1873,10 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, */ if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST) return png_icc_profile_error(png_ptr, colorspace, "sRGB", - (unsigned)intent, "invalid sRGB rendering intent"); + (unsigned)intent, "invalid sRGB rendering intent"); if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 && - colorspace->rendering_intent != intent) + colorspace->rendering_intent != intent) return png_icc_profile_error(png_ptr, colorspace, "sRGB", (unsigned)intent, "inconsistent rendering intents"); @@ -1888,8 +1890,8 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, * warn but overwrite the value with the correct one. */ if ((colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0 && - !png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy, - 100)) + !png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy, + 100)) png_chunk_report(png_ptr, "cHRM chunk does not match sRGB", PNG_CHUNK_ERROR); @@ -1897,7 +1899,7 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, * returns true when the 'from' argument corresponds to sRGB (2). */ (void)png_colorspace_check_gamma(png_ptr, colorspace, PNG_GAMMA_sRGB_INVERSE, - 2/*from sRGB*/); + 2/*from sRGB*/); /* intent: bugs in GCC force 'int' to be used as the parameter type. */ colorspace->rendering_intent = (png_uint_16)intent; @@ -1930,21 +1932,55 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace, static const png_byte D50_nCIEXYZ[12] = { 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d }; -int /* PRIVATE */ -png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length) +static int /* bool */ +icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_uint_32 profile_length) { if (profile_length < 132) return png_icc_profile_error(png_ptr, colorspace, name, profile_length, - "too short"); + "too short"); return 1; } +#ifdef PNG_READ_iCCP_SUPPORTED +int /* PRIVATE */ +png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace, + png_const_charp name, png_uint_32 profile_length) +{ + if (!icc_check_length(png_ptr, colorspace, name, profile_length)) + return 0; + + /* This needs to be here because the 'normal' check is in + * png_decompress_chunk, yet this happens after the attempt to + * png_malloc_base the required data. We only need this on read; on write + * the caller supplies the profile buffer so libpng doesn't allocate it. See + * the call to icc_check_length below (the write case). + */ +# ifdef PNG_SET_USER_LIMITS_SUPPORTED + else if (png_ptr->user_chunk_malloc_max > 0 && + png_ptr->user_chunk_malloc_max < profile_length) + return png_icc_profile_error(png_ptr, colorspace, name, profile_length, + "exceeds application limits"); +# elif PNG_USER_CHUNK_MALLOC_MAX > 0 + else if (PNG_USER_CHUNK_MALLOC_MAX < profile_length) + return png_icc_profile_error(png_ptr, colorspace, name, profile_length, + "exceeds libpng limits"); +# else /* !SET_USER_LIMITS */ + /* This will get compiled out on all 32-bit and better systems. */ + else if (PNG_SIZE_MAX < profile_length) + return png_icc_profile_error(png_ptr, colorspace, name, profile_length, + "exceeds system limits"); +# endif /* !SET_USER_LIMITS */ + + return 1; +} +#endif /* READ_iCCP */ + int /* PRIVATE */ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length, - png_const_bytep profile/* first 132 bytes only */, int color_type) + png_const_charp name, png_uint_32 profile_length, + png_const_bytep profile/* first 132 bytes only */, int color_type) { png_uint_32 temp; @@ -1956,18 +1992,18 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, temp = png_get_uint_32(profile); if (temp != profile_length) return png_icc_profile_error(png_ptr, colorspace, name, temp, - "length does not match profile"); + "length does not match profile"); temp = (png_uint_32) (*(profile+8)); if (temp > 3 && (profile_length & 3)) return png_icc_profile_error(png_ptr, colorspace, name, profile_length, - "invalid length"); + "invalid length"); temp = png_get_uint_32(profile+128); /* tag count: 12 bytes/tag */ if (temp > 357913930 || /* (2^32-4-132)/12: maximum possible tag count */ profile_length < 132+12*temp) /* truncated tag table */ return png_icc_profile_error(png_ptr, colorspace, name, temp, - "tag count too large"); + "tag count too large"); /* The 'intent' must be valid or we can't store it, ICC limits the intent to * 16 bits. @@ -1975,14 +2011,14 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, temp = png_get_uint_32(profile+64); if (temp >= 0xffff) /* The ICC limit */ return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid rendering intent"); + "invalid rendering intent"); /* This is just a warning because the profile may be valid in future * versions. */ if (temp >= PNG_sRGB_INTENT_LAST) (void)png_icc_profile_error(png_ptr, NULL, name, temp, - "intent outside defined range"); + "intent outside defined range"); /* At this point the tag table can't be checked because it hasn't necessarily * been loaded; however, various header fields can be checked. These checks @@ -1999,7 +2035,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, temp = png_get_uint_32(profile+36); /* signature 'ascp' */ if (temp != 0x61637370) return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid signature"); + "invalid signature"); /* Currently the PCS illuminant/adopted white point (the computational * white point) are required to be D50, @@ -2010,7 +2046,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, */ if (memcmp(profile+68, D50_nCIEXYZ, 12) != 0) (void)png_icc_profile_error(png_ptr, NULL, name, 0/*no tag value*/, - "PCS illuminant is not D50"); + "PCS illuminant is not D50"); /* The PNG spec requires this: * "If the iCCP chunk is present, the image samples conform to the colour @@ -2038,18 +2074,18 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, case 0x52474220: /* 'RGB ' */ if ((color_type & PNG_COLOR_MASK_COLOR) == 0) return png_icc_profile_error(png_ptr, colorspace, name, temp, - "RGB color space not permitted on grayscale PNG"); + "RGB color space not permitted on grayscale PNG"); break; case 0x47524159: /* 'GRAY' */ if ((color_type & PNG_COLOR_MASK_COLOR) != 0) return png_icc_profile_error(png_ptr, colorspace, name, temp, - "Gray color space not permitted on RGB PNG"); + "Gray color space not permitted on RGB PNG"); break; default: return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid ICC profile color space"); + "invalid ICC profile color space"); } /* It is up to the application to check that the profile class matches the @@ -2074,7 +2110,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, case 0x61627374: /* 'abst' */ /* May not be embedded in an image */ return png_icc_profile_error(png_ptr, colorspace, name, temp, - "invalid embedded Abstract ICC profile"); + "invalid embedded Abstract ICC profile"); case 0x6c696e6b: /* 'link' */ /* DeviceLink profiles cannot be interpreted in a non-device specific @@ -2084,7 +2120,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, * PNG. */ return png_icc_profile_error(png_ptr, colorspace, name, temp, - "unexpected DeviceLink ICC profile class"); + "unexpected DeviceLink ICC profile class"); case 0x6e6d636c: /* 'nmcl' */ /* A NamedColor profile is also device specific, however it doesn't @@ -2092,7 +2128,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, * certainly it will fail the tests below. */ (void)png_icc_profile_error(png_ptr, NULL, name, temp, - "unexpected NamedColor ICC profile class"); + "unexpected NamedColor ICC profile class"); break; default: @@ -2102,7 +2138,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, * understood profiles. */ (void)png_icc_profile_error(png_ptr, NULL, name, temp, - "unrecognized ICC profile class"); + "unrecognized ICC profile class"); break; } @@ -2118,7 +2154,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, default: return png_icc_profile_error(png_ptr, colorspace, name, temp, - "unexpected ICC PCS encoding"); + "unexpected ICC PCS encoding"); } return 1; @@ -2126,8 +2162,8 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace, int /* PRIVATE */ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length, - png_const_bytep profile /* header plus whole tag table */) + png_const_charp name, png_uint_32 profile_length, + png_const_bytep profile /* header plus whole tag table */) { png_uint_32 tag_count = png_get_uint_32(profile+128); png_uint_32 itag; @@ -2155,7 +2191,7 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace, * alignment. */ (void)png_icc_profile_error(png_ptr, NULL, name, tag_id, - "ICC profile tag start not a multiple of 4"); + "ICC profile tag start not a multiple of 4"); } /* This is a hard error; potentially it can cause read outside the @@ -2163,7 +2199,7 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace, */ if (tag_start > profile_length || tag_length > profile_length - tag_start) return png_icc_profile_error(png_ptr, colorspace, name, tag_id, - "ICC profile tag outside profile"); + "ICC profile tag outside profile"); } return 1; /* success, maybe with warnings */ @@ -2191,22 +2227,22 @@ static const struct */ /* adler32, crc32, MD5[4], intent, date, length, file-name */ PNG_ICC_CHECKSUM(0x0a3fd9f6, 0x3b8772b9, - PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0, - "2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc") + PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0, + "2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc") /* ICC sRGB v2 perceptual no black-compensation: */ PNG_ICC_CHECKSUM(0x4909e5e1, 0x427ebb21, - PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0, - "2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc") + PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0, + "2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc") PNG_ICC_CHECKSUM(0xfd2144a1, 0x306fd8ae, - PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0, - "2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc") + PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0, + "2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc") /* ICC sRGB v4 perceptual */ PNG_ICC_CHECKSUM(0x209c35d2, 0xbbef7812, - PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0, - "2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc") + PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0, + "2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc") /* The following profiles have no known MD5 checksum. If there is a match * on the (empty) MD5 the other fields are used to attempt a match and @@ -2214,8 +2250,8 @@ static const struct * which suggests that they were also made by Hewlett Packard. */ PNG_ICC_CHECKSUM(0xa054d762, 0x5d5129ce, - PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0, - "2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc") + PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0, + "2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc") /* This is a 'mntr' (display) profile with a mediaWhitePointTag that does not * match the D50 PCS illuminant in the header (it is in fact the D65 values, @@ -2225,17 +2261,17 @@ static const struct * chromaticAdaptationTag. */ PNG_ICC_CHECKSUM(0xf784f3fb, 0x182ea552, - PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/, - "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual") + PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/, + "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual") PNG_ICC_CHECKSUM(0x0398f3fc, 0xf29e526d, - PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/, - "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative") + PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/, + "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative") }; static int png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, - png_const_bytep profile, uLong adler) + png_const_bytep profile, uLong adler) { /* The quick check is to verify just the MD5 signature and trust the * rest of the data. Because the profile has already been verified for @@ -2319,7 +2355,7 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, * which is made irrelevant by this error. */ png_chunk_report(png_ptr, "known incorrect sRGB profile", - PNG_CHUNK_ERROR); + PNG_CHUNK_ERROR); } /* Warn that this being done; this isn't even an error since @@ -2329,8 +2365,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, else if (png_sRGB_checks[i].have_md5 == 0) { png_chunk_report(png_ptr, - "out-of-date sRGB profile with no signature", - PNG_CHUNK_WARNING); + "out-of-date sRGB profile with no signature", + PNG_CHUNK_WARNING); } return 1+png_sRGB_checks[i].is_broken; @@ -2353,38 +2389,36 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr, return 0; /* no match */ } -#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */ void /* PRIVATE */ png_icc_set_sRGB(png_const_structrp png_ptr, - png_colorspacerp colorspace, png_const_bytep profile, uLong adler) + png_colorspacerp colorspace, png_const_bytep profile, uLong adler) { /* Is this profile one of the known ICC sRGB profiles? If it is, just set * the sRGB information. */ -#if PNG_sRGB_PROFILE_CHECKS >= 0 if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler) != 0) -#endif (void)png_colorspace_set_sRGB(png_ptr, colorspace, (int)/*already checked*/png_get_uint_32(profile+64)); } +#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */ #endif /* sRGB */ int /* PRIVATE */ png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace, - png_const_charp name, png_uint_32 profile_length, png_const_bytep profile, - int color_type) + png_const_charp name, png_uint_32 profile_length, png_const_bytep profile, + int color_type) { if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0) return 0; - if (png_icc_check_length(png_ptr, colorspace, name, profile_length) != 0 && + if (icc_check_length(png_ptr, colorspace, name, profile_length) != 0 && png_icc_check_header(png_ptr, colorspace, name, profile_length, profile, - color_type) != 0 && + color_type) != 0 && png_icc_check_tag_table(png_ptr, colorspace, name, profile_length, - profile) != 0) + profile) != 0) { -# ifdef PNG_sRGB_SUPPORTED +# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0 /* If no sRGB support, don't try storing sRGB information */ png_icc_set_sRGB(png_ptr, colorspace, profile, 0); # endif @@ -2443,7 +2477,7 @@ png_colorspace_set_rgb_coefficients(png_structrp png_ptr) /* Check for an internal error. */ if (r+g+b != 32768) png_error(png_ptr, - "internal error handling cHRM coefficients"); + "internal error handling cHRM coefficients"); else { @@ -2469,7 +2503,7 @@ png_colorspace_set_rgb_coefficients(png_structrp png_ptr) static int /* PRIVATE */ png_gt(size_t a, size_t b) { - return a > b; + return a > b; } #else # define png_gt(a,b) ((a) > (b)) @@ -2477,9 +2511,9 @@ png_gt(size_t a, size_t b) void /* PRIVATE */ png_check_IHDR(png_const_structrp png_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_type, int compression_type, - int filter_type) + png_uint_32 width, png_uint_32 height, int bit_depth, + int color_type, int interlace_type, int compression_type, + int filter_type) { int error = 0; @@ -2496,7 +2530,7 @@ png_check_IHDR(png_const_structrp png_ptr, error = 1; } - if (png_gt(((width + 7) & (~7)), + if (png_gt(((width + 7) & (~7U)), ((PNG_SIZE_MAX - 48 /* big_row_buf hack */ - 1) /* filter byte */ @@ -2642,7 +2676,7 @@ png_check_IHDR(png_const_structrp png_ptr, int /* PRIVATE */ png_check_fp_number(png_const_charp string, png_size_t size, int *statep, - png_size_tp whereami) + png_size_tp whereami) { int state = *statep; png_size_t i = *whereami; @@ -2907,7 +2941,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size, */ if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */ { - czero = -exp_b10; /* PLUS 2 digits: TOTAL 3 */ + czero = (unsigned int)(-exp_b10); /* PLUS 2 digits: TOTAL 3 */ exp_b10 = 0; /* Dot added below before first output. */ } else @@ -3085,11 +3119,11 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size, if (exp_b10 < 0) { *ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */ - uexp_b10 = -exp_b10; + uexp_b10 = (unsigned int)(-exp_b10); } else - uexp_b10 = exp_b10; + uexp_b10 = (unsigned int)exp_b10; cdigits = 0; @@ -3151,9 +3185,9 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii, /* Avoid overflow here on the minimum integer. */ if (fp < 0) - *ascii++ = 45, num = -fp; + *ascii++ = 45, num = (png_uint_32)(-fp); else - num = fp; + num = (png_uint_32)fp; if (num <= 0x80000000) /* else overflowed */ { @@ -3805,25 +3839,25 @@ png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val) { if (value > 0 && value < 65535) { -# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - /* The same (unsigned int)->(double) constraints apply here as above, - * however in this case the (unsigned int) to (int) conversion can - * overflow on an ANSI-C90 compliant system so the cast needs to ensure - * that this is not possible. - */ - double r = floor(65535*pow((png_int_32)value/65535., - gamma_val*.00001)+.5); - return (png_uint_16)r; -# else - png_int_32 lg2 = png_log16bit(value); - png_fixed_point res; - - if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1) != 0) - return png_exp16bit(res); - - /* Overflow. */ - value = 0; -# endif +# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED + /* The same (unsigned int)->(double) constraints apply here as above, + * however in this case the (unsigned int) to (int) conversion can + * overflow on an ANSI-C90 compliant system so the cast needs to ensure + * that this is not possible. + */ + double r = floor(65535*pow((png_int_32)value/65535., + gamma_val*.00001)+.5); + return (png_uint_16)r; +# else + png_int_32 lg2 = png_log16bit(value); + png_fixed_point res; + + if (png_muldiv(&res, gamma_val, lg2, PNG_FP_1) != 0) + return png_exp16bit(res); + + /* Overflow. */ + value = 0; +# endif } return (png_uint_16)value; @@ -3862,7 +3896,7 @@ png_gamma_correct(png_structrp png_ptr, unsigned int value, */ static void png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, - PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) + PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) { /* Various values derived from 'shift': */ PNG_CONST unsigned int num = 1U << (8U - shift); @@ -3939,7 +3973,7 @@ png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, */ static void png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, - PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) + PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) { PNG_CONST unsigned int num = 1U << (8U - shift); PNG_CONST unsigned int max = (1U << (16U - shift))-1U; @@ -4007,7 +4041,7 @@ png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, */ static void png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable, - PNG_CONST png_fixed_point gamma_val) + PNG_CONST png_fixed_point gamma_val) { unsigned int i; png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256); @@ -4087,131 +4121,133 @@ png_destroy_gamma_table(png_structrp png_ptr) void /* PRIVATE */ png_build_gamma_table(png_structrp png_ptr, int bit_depth) { - png_debug(1, "in png_build_gamma_table"); - - /* Remove any existing table; this copes with multiple calls to - * png_read_update_info. The warning is because building the gamma tables - * multiple times is a performance hit - it's harmless but the ability to call - * png_read_update_info() multiple times is new in 1.5.6 so it seems sensible - * to warn if the app introduces such a hit. - */ - if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL) - { - png_warning(png_ptr, "gamma table being rebuilt"); - png_destroy_gamma_table(png_ptr); - } - - if (bit_depth <= 8) - { - png_build_8bit_table(png_ptr, &png_ptr->gamma_table, - png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma) : PNG_FP_1); + png_debug(1, "in png_build_gamma_table"); + + /* Remove any existing table; this copes with multiple calls to + * png_read_update_info. The warning is because building the gamma tables + * multiple times is a performance hit - it's harmless but the ability to + * call png_read_update_info() multiple times is new in 1.5.6 so it seems + * sensible to warn if the app introduces such a hit. + */ + if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL) + { + png_warning(png_ptr, "gamma table being rebuilt"); + png_destroy_gamma_table(png_ptr); + } + + if (bit_depth <= 8) + { + png_build_8bit_table(png_ptr, &png_ptr->gamma_table, + png_ptr->screen_gamma > 0 ? + png_reciprocal2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma) : PNG_FP_1); #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0) - { - png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1, - png_reciprocal(png_ptr->colorspace.gamma)); - - png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1, - png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : - png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); - } + if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0) + { + png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1, + png_reciprocal(png_ptr->colorspace.gamma)); + + png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1, + png_ptr->screen_gamma > 0 ? + png_reciprocal(png_ptr->screen_gamma) : + png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); + } #endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ - } + } #ifdef PNG_16BIT_SUPPORTED - else - { - png_byte shift, sig_bit; - - if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) - { - sig_bit = png_ptr->sig_bit.red; - - if (png_ptr->sig_bit.green > sig_bit) - sig_bit = png_ptr->sig_bit.green; - - if (png_ptr->sig_bit.blue > sig_bit) - sig_bit = png_ptr->sig_bit.blue; - } - else - sig_bit = png_ptr->sig_bit.gray; - - /* 16-bit gamma code uses this equation: - * - * ov = table[(iv & 0xff) >> gamma_shift][iv >> 8] - * - * Where 'iv' is the input color value and 'ov' is the output value - - * pow(iv, gamma). - * - * Thus the gamma table consists of up to 256 256-entry tables. The table - * is selected by the (8-gamma_shift) most significant of the low 8 bits of - * the color value then indexed by the upper 8 bits: - * - * table[low bits][high 8 bits] - * - * So the table 'n' corresponds to all those 'iv' of: - * - * ..<(n+1 << gamma_shift)-1> - * - */ - if (sig_bit > 0 && sig_bit < 16U) - /* shift == insignificant bits */ - shift = (png_byte)((16U - sig_bit) & 0xff); - - else - shift = 0; /* keep all 16 bits */ - - if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0) - { - /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively - * the significant bits in the *input* when the output will - * eventually be 8 bits. By default it is 11. - */ - if (shift < (16U - PNG_MAX_GAMMA_8)) - shift = (16U - PNG_MAX_GAMMA_8); - } - - if (shift > 8U) - shift = 8U; /* Guarantees at least one table! */ - - png_ptr->gamma_shift = shift; - - /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now - * PNG_COMPOSE). This effectively smashed the background calculation for - * 16-bit output because the 8-bit table assumes the result will be reduced - * to 8 bits. - */ - if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0) - png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift, - png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma) : PNG_FP_1); - - else - png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift, - png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma) : PNG_FP_1); + else + { + png_byte shift, sig_bit; + + if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0) + { + sig_bit = png_ptr->sig_bit.red; + + if (png_ptr->sig_bit.green > sig_bit) + sig_bit = png_ptr->sig_bit.green; + + if (png_ptr->sig_bit.blue > sig_bit) + sig_bit = png_ptr->sig_bit.blue; + } + else + sig_bit = png_ptr->sig_bit.gray; + + /* 16-bit gamma code uses this equation: + * + * ov = table[(iv & 0xff) >> gamma_shift][iv >> 8] + * + * Where 'iv' is the input color value and 'ov' is the output value - + * pow(iv, gamma). + * + * Thus the gamma table consists of up to 256 256-entry tables. The table + * is selected by the (8-gamma_shift) most significant of the low 8 bits + * of the color value then indexed by the upper 8 bits: + * + * table[low bits][high 8 bits] + * + * So the table 'n' corresponds to all those 'iv' of: + * + * ..<(n+1 << gamma_shift)-1> + * + */ + if (sig_bit > 0 && sig_bit < 16U) + /* shift == insignificant bits */ + shift = (png_byte)((16U - sig_bit) & 0xff); + + else + shift = 0; /* keep all 16 bits */ + + if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0) + { + /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively + * the significant bits in the *input* when the output will + * eventually be 8 bits. By default it is 11. + */ + if (shift < (16U - PNG_MAX_GAMMA_8)) + shift = (16U - PNG_MAX_GAMMA_8); + } + + if (shift > 8U) + shift = 8U; /* Guarantees at least one table! */ + + png_ptr->gamma_shift = shift; + + /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now + * PNG_COMPOSE). This effectively smashed the background calculation for + * 16-bit output because the 8-bit table assumes the result will be + * reduced to 8 bits. + */ + if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0) + png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift, + png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma) : PNG_FP_1); + + else + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift, + png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma, + png_ptr->screen_gamma) : PNG_FP_1); #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) - if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0) - { - png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift, - png_reciprocal(png_ptr->colorspace.gamma)); - - /* Notice that the '16 from 1' table should be full precision, however - * the lookup on this table still uses gamma_shift, so it can't be. - * TODO: fix this. - */ - png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift, - png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : - png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); - } + if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0) + { + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift, + png_reciprocal(png_ptr->colorspace.gamma)); + + /* Notice that the '16 from 1' table should be full precision, however + * the lookup on this table still uses gamma_shift, so it can't be. + * TODO: fix this. + */ + png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift, + png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : + png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); + } #endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ - } + } #endif /* 16BIT */ } #endif /* READ_GAMMA */ @@ -4224,11 +4260,11 @@ png_set_option(png_structrp png_ptr, int option, int onoff) if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT && (option & 1) == 0) { - int mask = 3 << option; - int setting = (2 + (onoff != 0)) << option; - int current = png_ptr->options; + png_uint_32 mask = 3 << option; + png_uint_32 setting = (2 + (onoff != 0)) << option; + png_uint_32 current = png_ptr->options; - png_ptr->options = (png_byte)(((current & ~mask) | setting) & 0xff); + png_ptr->options = (png_uint_32)(((current & ~mask) | setting) & 0xff); return (current & mask) >> option; } diff --git a/src/3rdparty/libpng/png.h b/src/3rdparty/libpng/png.h index 4d03dfc136..e4cf032816 100644 --- a/src/3rdparty/libpng/png.h +++ b/src/3rdparty/libpng/png.h @@ -1,9 +1,9 @@ /* png.h - header file for PNG reference library * - * libpng version 1.6.20, December 3, 2015 + * libpng version 1.6.28, January 5, 2017 * - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -12,7 +12,7 @@ * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.6.20, December 3, 2015: + * libpng versions 0.97, January 1998, through 1.6.28, January 5, 2017: * Glenn Randers-Pehrson. * See also "Contributing Authors", below. */ @@ -25,8 +25,8 @@ * * This code is released under the libpng license. * - * libpng versions 1.0.7, July 1, 2000, through 1.6.20, December 3, 2015, are - * Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, are + * libpng versions 1.0.7, July 1, 2000 through 1.6.28, January 5, 2017 are + * Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are * derived from libpng-1.0.6, and are distributed according to the same * disclaimer and license as libpng-1.0.6 with the following individuals * added to the list of Contributing Authors: @@ -37,6 +37,7 @@ * Cosmin Truta * Gilles Vollant * James Yu + * Mandar Sahastrabuddhe * * and with the following additions to the disclaimer: * @@ -47,6 +48,10 @@ * risk of satisfactory quality, performance, accuracy, and effort is with * the user. * + * Some files in the "contrib" directory and some configure-generated + * files that are distributed with libpng have other copyright owners and + * are released under other open source licenses. + * * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from * libpng-0.96, and are distributed according to the same disclaimer and @@ -70,6 +75,9 @@ * Greg Roelofs * Tom Tanner * + * Some files in the "scripts" directory have other copyright owners + * but are released under this license. + * * libpng versions 0.5, May 1995, through 0.88, January 1996, are * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * @@ -109,6 +117,29 @@ * appreciated. * * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE. + * + * TRADEMARK: + * + * The name "libpng" has not been registered by the Copyright owner + * as a trademark in any jurisdiction. However, because libpng has + * been distributed and maintained world-wide, continually since 1995, + * the Copyright owner claims "common-law trademark protection" in any + * jurisdiction where common-law trademark is recognized. + * + * OSI CERTIFICATION: + * + * Libpng is OSI Certified Open Source Software. OSI Certified Open Source is + * a certification mark of the Open Source Initiative. OSI has not addressed + * the additional disclaimers inserted at version 1.0.7. + * + * EXPORT CONTROL: + * + * The Copyright owner believes that the Export Control Classification + * Number (ECCN) for libpng is EAR99, which means not subject to export + * controls or International Traffic in Arms Regulations (ITAR) because + * it is open source, publicly available software, that does not contain + * any encryption software. See the EAR, paragraphs 734.3(b)(3) and + * 734.7(b). */ /* @@ -121,12 +152,6 @@ * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). */ -/* - * Libpng is OSI Certified Open Source Software. OSI Certified Open Source is - * a certification mark of the Open Source Initiative. OSI has not addressed - * the additional disclaimers inserted at version 1.0.7. - */ - /* * The contributing authors would like to thank all those who helped * with testing, bug fixes, and patience. This wouldn't have been @@ -182,11 +207,11 @@ * ... * 1.0.19 10 10019 10.so.0.19[.0] * ... - * 1.2.53 13 10253 12.so.0.53[.0] + * 1.2.57 13 10257 12.so.0.57[.0] * ... - * 1.5.23 15 10523 15.so.15.23[.0] + * 1.5.28 15 10527 15.so.15.28[.0] * ... - * 1.6.20 16 10620 16.so.16.20[.0] + * 1.6.28 16 10628 16.so.16.28[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -214,13 +239,13 @@ * Y2K compliance in libpng: * ========================= * - * December 3, 2015 + * January 5, 2017 * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. * * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.6.20 are Y2K compliant. It is my belief that + * upward through 1.6.28 are Y2K compliant. It is my belief that * earlier versions were also Y2K compliant. * * Libpng only has two year fields. One is a 2-byte unsigned integer @@ -282,9 +307,8 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.20" -#define PNG_HEADER_VERSION_STRING \ - " libpng version 1.6.20 - December 3, 2015\n" +#define PNG_LIBPNG_VER_STRING "1.6.28" +#define PNG_HEADER_VERSION_STRING " libpng version 1.6.28 - January 5, 2017\n" #define PNG_LIBPNG_VER_SONUM 16 #define PNG_LIBPNG_VER_DLLNUM 16 @@ -292,7 +316,7 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 6 -#define PNG_LIBPNG_VER_RELEASE 20 +#define PNG_LIBPNG_VER_RELEASE 28 /* This should match the numeric part of the final component of * PNG_LIBPNG_VER_STRING, omitting any leading zero: @@ -323,20 +347,20 @@ * version 1.0.0 was mis-numbered 100 instead of 10000). From * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10620 /* 1.6.20 */ +#define PNG_LIBPNG_VER 10628 /* 1.6.28 */ /* Library configuration: these options cannot be changed after * the library has been built. */ #ifndef PNGLCONF_H - /* If pnglibconf.h is missing, you can - * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h - */ +/* If pnglibconf.h is missing, you can + * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h + */ # include "pnglibconf.h" #endif #ifndef PNG_VERSION_INFO_ONLY - /* Machine specific configuration. */ +/* Machine specific configuration. */ # include "pngconf.h" #endif @@ -433,7 +457,7 @@ extern "C" { /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef char* png_libpng_version_1_6_20; +typedef char* png_libpng_version_1_6_28; /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. * @@ -626,17 +650,17 @@ typedef png_time * * png_timepp; */ typedef struct png_unknown_chunk_t { - png_byte name[5]; /* Textual chunk name with '\0' terminator */ - png_byte *data; /* Data, should not be modified on read! */ - png_size_t size; - - /* On write 'location' must be set using the flag values listed below. - * Notice that on read it is set by libpng however the values stored have - * more bits set than are listed below. Always treat the value as a - * bitmask. On write set only one bit - setting multiple bits may cause the - * chunk to be written in multiple places. - */ - png_byte location; /* mode of operation at read time */ + png_byte name[5]; /* Textual chunk name with '\0' terminator */ + png_byte *data; /* Data, should not be modified on read! */ + png_size_t size; + + /* On write 'location' must be set using the flag values listed below. + * Notice that on read it is set by libpng however the values stored have + * more bits set than are listed below. Always treat the value as a + * bitmask. On write set only one bit - setting multiple bits may cause the + * chunk to be written in multiple places. + */ + png_byte location; /* mode of operation at read time */ } png_unknown_chunk; @@ -734,24 +758,22 @@ typedef png_unknown_chunk * * png_unknown_chunkpp; * data in the info_struct to be written into the output file. The values * of the PNG_INFO_ defines should NOT be changed. */ -#define PNG_INFO_gAMA 0x0001 -#define PNG_INFO_sBIT 0x0002 -#define PNG_INFO_cHRM 0x0004 -#define PNG_INFO_PLTE 0x0008 -#define PNG_INFO_tRNS 0x0010 -#define PNG_INFO_bKGD 0x0020 -#define PNG_INFO_hIST 0x0040 -#define PNG_INFO_pHYs 0x0080 -#define PNG_INFO_oFFs 0x0100 -#define PNG_INFO_tIME 0x0200 -#define PNG_INFO_pCAL 0x0400 -#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ -#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ -#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ -#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ -#if INT_MAX >= 0x8000 /* else this might break */ -#define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */ -#endif +#define PNG_INFO_gAMA 0x0001U +#define PNG_INFO_sBIT 0x0002U +#define PNG_INFO_cHRM 0x0004U +#define PNG_INFO_PLTE 0x0008U +#define PNG_INFO_tRNS 0x0010U +#define PNG_INFO_bKGD 0x0020U +#define PNG_INFO_hIST 0x0040U +#define PNG_INFO_pHYs 0x0080U +#define PNG_INFO_oFFs 0x0100U +#define PNG_INFO_tIME 0x0200U +#define PNG_INFO_pCAL 0x0400U +#define PNG_INFO_sRGB 0x0800U /* GR-P, 0.96a */ +#define PNG_INFO_iCCP 0x1000U /* ESR, 1.0.6 */ +#define PNG_INFO_sPLT 0x2000U /* ESR, 1.0.6 */ +#define PNG_INFO_sCAL 0x4000U /* ESR, 1.0.6 */ +#define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */ /* This is used for the transformation routines, as some of them * change these values for the row. It also should enable using @@ -1322,7 +1344,7 @@ PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr)); #endif #ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED -#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */ +#define PNG_READ_16_TO_8_SUPPORTED /* Name prior to 1.5.4 */ /* Strip the second byte of information from a 16-bit depth file. */ PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr)); #endif @@ -1473,8 +1495,8 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method, #define PNG_FILTER_UP 0x20 #define PNG_FILTER_AVG 0x40 #define PNG_FILTER_PAETH 0x80 -#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ - PNG_FILTER_AVG | PNG_FILTER_PAETH) +#define PNG_FAST_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP) +#define PNG_ALL_FILTERS (PNG_FAST_FILTERS | PNG_FILTER_AVG | PNG_FILTER_PAETH) /* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. * These defines should NOT be changed. @@ -1751,21 +1773,21 @@ PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr, #define PNG_SET_WILL_FREE_DATA 1 #define PNG_USER_WILL_FREE_DATA 2 /* Flags for png_ptr->free_me and info_ptr->free_me */ -#define PNG_FREE_HIST 0x0008 -#define PNG_FREE_ICCP 0x0010 -#define PNG_FREE_SPLT 0x0020 -#define PNG_FREE_ROWS 0x0040 -#define PNG_FREE_PCAL 0x0080 -#define PNG_FREE_SCAL 0x0100 +#define PNG_FREE_HIST 0x0008U +#define PNG_FREE_ICCP 0x0010U +#define PNG_FREE_SPLT 0x0020U +#define PNG_FREE_ROWS 0x0040U +#define PNG_FREE_PCAL 0x0080U +#define PNG_FREE_SCAL 0x0100U #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_FREE_UNKN 0x0200 +# define PNG_FREE_UNKN 0x0200U #endif -/* PNG_FREE_LIST 0x0400 removed in 1.6.0 because it is ignored */ -#define PNG_FREE_PLTE 0x1000 -#define PNG_FREE_TRNS 0x2000 -#define PNG_FREE_TEXT 0x4000 -#define PNG_FREE_ALL 0x7fff -#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ +/* PNG_FREE_LIST 0x0400U removed in 1.6.0 because it is ignored */ +#define PNG_FREE_PLTE 0x1000U +#define PNG_FREE_TRNS 0x2000U +#define PNG_FREE_TEXT 0x4000U +#define PNG_FREE_ALL 0x7fffU +#define PNG_FREE_MUL 0x4220U /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ #ifdef PNG_USER_MEM_SUPPORTED PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr, @@ -2271,8 +2293,10 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to * be processed by libpng. */ +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, int keep, png_const_bytep chunk_list, int num_chunks)); +#endif /* HANDLE_AS_UNKNOWN */ /* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned; * the result is therefore true (non-zero) if special handling is required, @@ -2280,7 +2304,7 @@ PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, */ PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr, png_const_bytep chunk_name)); -#endif +#endif /* SET_UNKNOWN_CHUNKS */ #ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr, @@ -2501,33 +2525,37 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ -# define png_composite(composite, fg, alpha, bg) \ - { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ - * (png_uint_16)(alpha) \ - + (png_uint_16)(bg)*(png_uint_16)(255 \ - - (png_uint_16)(alpha)) + 128); \ - (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); } - -# define png_composite_16(composite, fg, alpha, bg) \ - { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ - * (png_uint_32)(alpha) \ - + (png_uint_32)(bg)*(65535 \ - - (png_uint_32)(alpha)) + 32768); \ - (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); } +# define png_composite(composite, fg, alpha, bg) \ + { \ + png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ + * (png_uint_16)(alpha) \ + + (png_uint_16)(bg)*(png_uint_16)(255 \ + - (png_uint_16)(alpha)) + 128); \ + (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); \ + } + +# define png_composite_16(composite, fg, alpha, bg) \ + { \ + png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ + * (png_uint_32)(alpha) \ + + (png_uint_32)(bg)*(65535 \ + - (png_uint_32)(alpha)) + 32768); \ + (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); \ + } #else /* Standard method using integer division */ -# define png_composite(composite, fg, alpha, bg) \ - (composite) = \ - (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \ - (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ - 127) / 255)) - -# define png_composite_16(composite, fg, alpha, bg) \ - (composite) = \ - (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \ - (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ - 32767) / 65535)) +# define png_composite(composite, fg, alpha, bg) \ + (composite) = \ + (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \ + (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ + 127) / 255)) + +# define png_composite_16(composite, fg, alpha, bg) \ + (composite) = \ + (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \ + (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ + 32767) / 65535)) #endif /* READ_COMPOSITE_NODIV */ #ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED @@ -2563,38 +2591,38 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); * format for negative values, which is almost certainly true. */ # define PNG_get_uint_32(buf) \ - (((png_uint_32)(*(buf)) << 24) + \ - ((png_uint_32)(*((buf) + 1)) << 16) + \ - ((png_uint_32)(*((buf) + 2)) << 8) + \ - ((png_uint_32)(*((buf) + 3)))) + (((png_uint_32)(*(buf)) << 24) + \ + ((png_uint_32)(*((buf) + 1)) << 16) + \ + ((png_uint_32)(*((buf) + 2)) << 8) + \ + ((png_uint_32)(*((buf) + 3)))) /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the * function) incorrectly returned a value of type png_uint_32. */ # define PNG_get_uint_16(buf) \ - ((png_uint_16) \ - (((unsigned int)(*(buf)) << 8) + \ - ((unsigned int)(*((buf) + 1))))) + ((png_uint_16) \ + (((unsigned int)(*(buf)) << 8) + \ + ((unsigned int)(*((buf) + 1))))) # define PNG_get_int_32(buf) \ - ((png_int_32)((*(buf) & 0x80) \ - ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \ - : (png_int_32)png_get_uint_32(buf))) + ((png_int_32)((*(buf) & 0x80) \ + ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \ + : (png_int_32)png_get_uint_32(buf))) - /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h, - * but defining a macro name prefixed with PNG_PREFIX. - */ +/* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h, + * but defining a macro name prefixed with PNG_PREFIX. + */ # ifndef PNG_PREFIX -# define png_get_uint_32(buf) PNG_get_uint_32(buf) -# define png_get_uint_16(buf) PNG_get_uint_16(buf) -# define png_get_int_32(buf) PNG_get_int_32(buf) +# define png_get_uint_32(buf) PNG_get_uint_32(buf) +# define png_get_uint_16(buf) PNG_get_uint_16(buf) +# define png_get_int_32(buf) PNG_get_int_32(buf) # endif #else # ifdef PNG_PREFIX - /* No macros; revert to the (redefined) function */ -# define PNG_get_uint_32 (png_get_uint_32) -# define PNG_get_uint_16 (png_get_uint_16) -# define PNG_get_int_32 (png_get_int_32) + /* No macros; revert to the (redefined) function */ +# define PNG_get_uint_32 (png_get_uint_32) +# define PNG_get_uint_16 (png_get_uint_16) +# define PNG_get_int_32 (png_get_int_32) # endif #endif @@ -2889,12 +2917,19 @@ typedef struct * is the minimum 'row stride', the minimum count of components between each * row. For a color-mapped image this is the minimum number of bytes in a * row. + * + * WARNING: this macro overflows for some images with more than one component + * and very large image widths. libpng will refuse to process an image where + * this macro would overflow. */ #define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\ (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride)) /* Return the size, in bytes, of an image buffer given a png_image and a row * stride - the number of components to leave space for in each row. + * + * WARNING: this macro overflows a 32-bit integer for some large PNG images, + * libpng will refuse to process an image where such an overflow would occur. */ #define PNG_IMAGE_SIZE(image)\ @@ -3015,7 +3050,6 @@ PNG_EXPORT(238, void, png_image_free, (png_imagep image)); #endif /* SIMPLIFIED_READ */ #ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED -#ifdef PNG_STDIO_SUPPORTED /* WRITE APIS * ---------- * For write you must initialize a png_image structure to describe the image to @@ -3032,6 +3066,7 @@ PNG_EXPORT(238, void, png_image_free, (png_imagep image)); * values do not correspond to the colors in sRGB. * colormap_entries: set to the number of entries in the color-map (0 to 256) */ +#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image, const char *file, int convert_to_8bit, const void *buffer, png_int_32 row_stride, const void *colormap)); @@ -3041,8 +3076,9 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file, int convert_to_8_bit, const void *buffer, png_int_32 row_stride, const void *colormap)); /* Write the image to the given (FILE*). */ +#endif /* SIMPLIFIED_WRITE_STDIO */ -/* With both write APIs if image is in one of the linear formats with 16-bit +/* With all write APIs if image is in one of the linear formats with 16-bit * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG * gamma encoded according to the sRGB specification, otherwise a 16-bit linear * encoded PNG file is written. @@ -3054,13 +3090,103 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file, * * With all APIs row_stride is handled as in the read APIs - it is the spacing * from one row to the next in component sized units (1 or 2 bytes) and if - * negative indicates a bottom-up row layout in the buffer. If row_stride is zero, - * libpng will calculate it for you from the image width and number of channels. + * negative indicates a bottom-up row layout in the buffer. If row_stride is + * zero, libpng will calculate it for you from the image width and number of + * channels. * - * Note that the write API does not support interlacing, sub-8-bit pixels, indexed - * PNG (color_type 3) or most ancillary chunks. + * Note that the write API does not support interlacing, sub-8-bit pixels or + * most ancillary chunks. If you need to write text chunks (e.g. for copyright + * notices) you need to use one of the other APIs. */ -#endif /* STDIO */ + +PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory, + png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8_bit, + const void *buffer, png_int_32 row_stride, const void *colormap)); + /* Write the image to the given memory buffer. The function both writes the + * whole PNG data stream to *memory and updates *memory_bytes with the count + * of bytes written. + * + * 'memory' may be NULL. In this case *memory_bytes is not read however on + * success the number of bytes which would have been written will still be + * stored in *memory_bytes. On failure *memory_bytes will contain 0. + * + * If 'memory' is not NULL it must point to memory[*memory_bytes] of + * writeable memory. + * + * If the function returns success memory[*memory_bytes] (if 'memory' is not + * NULL) contains the written PNG data. *memory_bytes will always be less + * than or equal to the original value. + * + * If the function returns false and *memory_bytes was not changed an error + * occured during write. If *memory_bytes was changed, or is not 0 if + * 'memory' was NULL, the write would have succeeded but for the memory + * buffer being too small. *memory_bytes contains the required number of + * bytes and will be bigger that the original value. + */ + +#define png_image_write_get_memory_size(image, size, convert_to_8_bit, buffer,\ + row_stride, colormap)\ + png_image_write_to_memory(&(image), 0, &(size), convert_to_8_bit, buffer,\ + row_stride, colormap) + /* Return the amount of memory in 'size' required to compress this image. + * The png_image structure 'image' must be filled in as in the above + * function and must not be changed before the actual write call, the buffer + * and all other parameters must also be identical to that in the final + * write call. The 'size' variable need not be initialized. + * + * NOTE: the macro returns true/false, if false is returned 'size' will be + * set to zero and the write failed and probably will fail if tried again. + */ + +/* You can pre-allocate the buffer by making sure it is of sufficient size + * regardless of the amount of compression achieved. The buffer size will + * always be bigger than the original image and it will never be filled. The + * following macros are provided to assist in allocating the buffer. + */ +#define PNG_IMAGE_DATA_SIZE(image) (PNG_IMAGE_SIZE(image)+(image).height) + /* The number of uncompressed bytes in the PNG byte encoding of the image; + * uncompressing the PNG IDAT data will give this number of bytes. + * + * NOTE: while PNG_IMAGE_SIZE cannot overflow for an image in memory this + * macro can because of the extra bytes used in the PNG byte encoding. You + * need to avoid this macro if your image size approaches 2^30 in width or + * height. The same goes for the remainder of these macros; they all produce + * bigger numbers than the actual in-memory image size. + */ +#ifndef PNG_ZLIB_MAX_SIZE +# define PNG_ZLIB_MAX_SIZE(b) ((b)+(((b)+7U)>>3)+(((b)+63U)>>6)+11U) + /* An upper bound on the number of compressed bytes given 'b' uncompressed + * bytes. This is based on deflateBounds() in zlib; different + * implementations of zlib compression may conceivably produce more data so + * if your zlib implementation is not zlib itself redefine this macro + * appropriately. + */ +#endif + +#define PNG_IMAGE_COMPRESSED_SIZE_MAX(image)\ + PNG_ZLIB_MAX_SIZE((png_alloc_size_t)PNG_IMAGE_DATA_SIZE(image)) + /* An upper bound on the size of the data in the PNG IDAT chunks. */ + +#define PNG_IMAGE_PNG_SIZE_MAX_(image, image_size)\ + ((8U/*sig*/+25U/*IHDR*/+16U/*gAMA*/+44U/*cHRM*/+12U/*IEND*/+\ + (((image).format&PNG_FORMAT_FLAG_COLORMAP)?/*colormap: PLTE, tRNS*/\ + 12U+3U*(image).colormap_entries/*PLTE data*/+\ + (((image).format&PNG_FORMAT_FLAG_ALPHA)?\ + 12U/*tRNS*/+(image).colormap_entries:0U):0U)+\ + 12U)+(12U*((image_size)/PNG_ZBUF_SIZE))/*IDAT*/+(image_size)) + /* A helper for the following macro; if your compiler cannot handle the + * following macro use this one with the result of + * PNG_IMAGE_COMPRESSED_SIZE_MAX(image) as the second argument (most + * compilers should handle this just fine.) + */ + +#define PNG_IMAGE_PNG_SIZE_MAX(image)\ + PNG_IMAGE_PNG_SIZE_MAX_(image, PNG_IMAGE_COMPRESSED_SIZE_MAX(image)) + /* An upper bound on the total length of the PNG data stream for 'image'. + * The result is of type png_alloc_size_t, on 32-bit systems this may + * overflow even though PNG_IMAGE_DATA_SIZE does not overflow; the write will + * run out of buffer space but return a corrected size which should work. + */ #endif /* SIMPLIFIED_WRITE */ /******************************************************************************* * END OF SIMPLIFIED API @@ -3094,7 +3220,11 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file, #endif #define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */ #define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */ -#define PNG_OPTION_NEXT 6 /* Next option - numbers must be even */ +#ifdef PNG_MIPS_MSA_API_SUPPORTED +# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */ +#endif +#define PNG_IGNORE_ADLER32 8 +#define PNG_OPTION_NEXT 10 /* Next option - numbers must be even */ /* Return values: NOTE: there are four values and 'off' is *not* zero */ #define PNG_OPTION_UNSET 0 /* Unset - defaults to off */ @@ -3118,7 +3248,7 @@ PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, * one to use is one more than this.) */ #ifdef PNG_EXPORT_LAST_ORDINAL - PNG_EXPORT_LAST_ORDINAL(244); + PNG_EXPORT_LAST_ORDINAL(245); #endif #ifdef __cplusplus diff --git a/src/3rdparty/libpng/pngconf.h b/src/3rdparty/libpng/pngconf.h index 92f250000c..5e8b40bcfb 100644 --- a/src/3rdparty/libpng/pngconf.h +++ b/src/3rdparty/libpng/pngconf.h @@ -1,9 +1,9 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.6.20, December 3, 2015 + * libpng version 1.6.28, January 5, 2017 * - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -188,27 +188,27 @@ * compatible with GCC or Visual C because of different calling conventions. */ # if PNG_API_RULE == 2 - /* If this line results in an error, either because __watcall is not - * understood or because of a redefine just below you cannot use *this* - * build of the library with the compiler you are using. *This* build was - * build using Watcom and applications must also be built using Watcom! - */ + /* If this line results in an error, either because __watcall is not + * understood or because of a redefine just below you cannot use *this* + * build of the library with the compiler you are using. *This* build was + * build using Watcom and applications must also be built using Watcom! + */ # define PNGCAPI __watcall # endif # if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800)) # define PNGCAPI __cdecl # if PNG_API_RULE == 1 - /* If this line results in an error __stdcall is not understood and - * PNG_API_RULE should not have been set to '1'. - */ + /* If this line results in an error __stdcall is not understood and + * PNG_API_RULE should not have been set to '1'. + */ # define PNGAPI __stdcall # endif # else - /* An older compiler, or one not detected (erroneously) above, - * if necessary override on the command line to get the correct - * variants for the compiler. - */ + /* An older compiler, or one not detected (erroneously) above, + * if necessary override on the command line to get the correct + * variants for the compiler. + */ # ifndef PNGCAPI # define PNGCAPI _cdecl # endif @@ -225,10 +225,10 @@ # if (defined(_MSC_VER) && _MSC_VER < 800) ||\ (defined(__BORLANDC__) && __BORLANDC__ < 0x500) - /* older Borland and MSC - * compilers used '__export' and required this to be after - * the type. - */ + /* older Borland and MSC + * compilers used '__export' and required this to be after + * the type. + */ # ifndef PNG_EXPORT_TYPE # define PNG_EXPORT_TYPE(type) type PNG_IMPEXP # endif @@ -244,9 +244,9 @@ # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) # define PNGAPI _System # else /* !Windows/x86 && !OS/2 */ - /* Use the defaults, or define PNG*API on the command line (but - * this will have to be done for every compile!) - */ + /* Use the defaults, or define PNG*API on the command line (but + * this will have to be done for every compile!) + */ # endif /* other system, !OS/2 */ #endif /* !Windows/x86 */ @@ -267,7 +267,7 @@ */ #ifndef PNG_IMPEXP # if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) - /* This forces use of a DLL, disallowing static linking */ + /* This forces use of a DLL, disallowing static linking */ # define PNG_IMPEXP PNG_DLL_IMPORT # endif @@ -340,7 +340,7 @@ * less efficient code. */ # if defined(__clang__) && defined(__has_attribute) - /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */ + /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */ # if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__) # define PNG_USE_RESULT __attribute__((__warn_unused_result__)) # endif @@ -507,9 +507,9 @@ # error "libpng requires a signed 32-bit (or more) type" #endif -#if UINT_MAX > 4294967294 +#if UINT_MAX > 4294967294U typedef unsigned int png_uint_32; -#elif ULONG_MAX > 4294967294 +#elif ULONG_MAX > 4294967294U typedef unsigned long int png_uint_32; #else # error "libpng requires an unsigned 32-bit (or more) type" diff --git a/src/3rdparty/libpng/pngdebug.h b/src/3rdparty/libpng/pngdebug.h index 6a01b106ed..15a7ed0c95 100644 --- a/src/3rdparty/libpng/pngdebug.h +++ b/src/3rdparty/libpng/pngdebug.h @@ -2,7 +2,7 @@ /* pngdebug.h - Debugging macros for libpng, also used in pngtest.c * * Last changed in libpng 1.6.8 [December 19, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * diff --git a/src/3rdparty/libpng/pngerror.c b/src/3rdparty/libpng/pngerror.c index bdb959ee51..00d76f7c05 100644 --- a/src/3rdparty/libpng/pngerror.c +++ b/src/3rdparty/libpng/pngerror.c @@ -1,8 +1,8 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.6.15 [November 20, 2014] - * Copyright (c) 1998-2014 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -26,7 +26,7 @@ static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr, #ifdef PNG_WARNINGS_SUPPORTED static void /* PRIVATE */ png_default_warning PNGARG((png_const_structrp png_ptr, - png_const_charp warning_message)); + png_const_charp warning_message)); #endif /* WARNINGS */ /* This function is called whenever there is a fatal error. This function @@ -37,14 +37,14 @@ png_default_warning PNGARG((png_const_structrp png_ptr, #ifdef PNG_ERROR_TEXT_SUPPORTED PNG_FUNCTION(void,PNGAPI png_error,(png_const_structrp png_ptr, png_const_charp error_message), - PNG_NORETURN) + PNG_NORETURN) { #ifdef PNG_ERROR_NUMBERS_SUPPORTED char msg[16]; if (png_ptr != NULL) { if ((png_ptr->flags & - (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0 + (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0) { if (*error_message == PNG_LITERAL_SHARP) { @@ -65,18 +65,18 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message), else error_message += offset; - } + } - else - { - if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0) + else { - msg[0] = '0'; - msg[1] = '\0'; - error_message = msg; + if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0) + { + msg[0] = '0'; + msg[1] = '\0'; + error_message = msg; + } } - } - } + } } #endif if (png_ptr != NULL && png_ptr->error_fn != NULL) @@ -110,7 +110,7 @@ png_err,(png_const_structrp png_ptr),PNG_NORETURN) */ size_t png_safecat(png_charp buffer, size_t bufsize, size_t pos, - png_const_charp string) + png_const_charp string) { if (buffer != NULL && pos < bufsize) { @@ -131,7 +131,7 @@ png_safecat(png_charp buffer, size_t bufsize, size_t pos, */ png_charp png_format_number(png_const_charp start, png_charp end, int format, - png_alloc_size_t number) + png_alloc_size_t number) { int count = 0; /* number of digits output */ int mincount = 1; /* minimum number required */ @@ -233,7 +233,7 @@ png_warning(png_const_structrp png_ptr, png_const_charp warning_message) } if (png_ptr != NULL && png_ptr->warning_fn != NULL) (*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr), - warning_message + offset); + warning_message + offset); else png_default_warning(png_ptr, warning_message + offset); } @@ -245,7 +245,7 @@ png_warning(png_const_structrp png_ptr, png_const_charp warning_message) */ void png_warning_parameter(png_warning_parameters p, int number, - png_const_charp string) + png_const_charp string) { if (number > 0 && number <= PNG_WARNING_PARAMETER_COUNT) (void)png_safecat(p[number-1], (sizeof p[number-1]), 0, string); @@ -253,7 +253,7 @@ png_warning_parameter(png_warning_parameters p, int number, void png_warning_parameter_unsigned(png_warning_parameters p, int number, int format, - png_alloc_size_t value) + png_alloc_size_t value) { char buffer[PNG_NUMBER_BUFFER_SIZE]; png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value)); @@ -261,7 +261,7 @@ png_warning_parameter_unsigned(png_warning_parameters p, int number, int format, void png_warning_parameter_signed(png_warning_parameters p, int number, int format, - png_int_32 value) + png_int_32 value) { png_alloc_size_t u; png_charp str; @@ -282,7 +282,7 @@ png_warning_parameter_signed(png_warning_parameters p, int number, int format, void png_formatted_warning(png_const_structrp png_ptr, png_warning_parameters p, - png_const_charp message) + png_const_charp message) { /* The internal buffer is just 192 bytes - enough for all our messages, * overflow doesn't happen because this code checks! If someone figures @@ -391,10 +391,10 @@ png_benign_error(png_const_structrp png_ptr, png_const_charp error_message) void /* PRIVATE */ png_app_warning(png_const_structrp png_ptr, png_const_charp error_message) { - if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0) - png_warning(png_ptr, error_message); - else - png_error(png_ptr, error_message); + if ((png_ptr->flags & PNG_FLAG_APP_WARNINGS_WARN) != 0) + png_warning(png_ptr, error_message); + else + png_error(png_ptr, error_message); # ifndef PNG_ERROR_TEXT_SUPPORTED PNG_UNUSED(error_message) @@ -404,10 +404,10 @@ png_app_warning(png_const_structrp png_ptr, png_const_charp error_message) void /* PRIVATE */ png_app_error(png_const_structrp png_ptr, png_const_charp error_message) { - if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0) - png_warning(png_ptr, error_message); - else - png_error(png_ptr, error_message); + if ((png_ptr->flags & PNG_FLAG_APP_ERRORS_WARN) != 0) + png_warning(png_ptr, error_message); + else + png_error(png_ptr, error_message); # ifndef PNG_ERROR_TEXT_SUPPORTED PNG_UNUSED(error_message) @@ -478,7 +478,7 @@ png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp #if defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED) PNG_FUNCTION(void,PNGAPI png_chunk_error,(png_const_structrp png_ptr, png_const_charp error_message), - PNG_NORETURN) + PNG_NORETURN) { char msg[18+PNG_MAX_ERROR_TEXT]; if (png_ptr == NULL) @@ -573,7 +573,7 @@ png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN) { # define fixed_message "fixed point overflow in " # define fixed_message_ln ((sizeof fixed_message)-1) - int iin; + unsigned int iin; char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT]; memcpy(msg, fixed_message, fixed_message_ln); iin = 0; @@ -620,7 +620,7 @@ png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn, else { png_ptr->jmp_buf_ptr = png_voidcast(jmp_buf *, - png_malloc_warn(png_ptr, jmp_buf_size)); + png_malloc_warn(png_ptr, jmp_buf_size)); if (png_ptr->jmp_buf_ptr == NULL) return NULL; /* new NULL return on OOM */ @@ -709,7 +709,7 @@ png_free_jmpbuf(png_structrp png_ptr) */ static PNG_FUNCTION(void /* PRIVATE */, png_default_error,(png_const_structrp png_ptr, png_const_charp error_message), - PNG_NORETURN) + PNG_NORETURN) { #ifdef PNG_CONSOLE_IO_SUPPORTED #ifdef PNG_ERROR_NUMBERS_SUPPORTED @@ -883,7 +883,7 @@ png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode) */ PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message), - PNG_NORETURN) + PNG_NORETURN) { const png_const_structrp png_ptr = png_nonconst_ptr; png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr); @@ -906,7 +906,7 @@ png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message), /* Missing longjmp buffer, the following is to help debugging: */ { size_t pos = png_safecat(image->message, (sizeof image->message), 0, - "bad longjmp: "); + "bad longjmp: "); png_safecat(image->message, (sizeof image->message), pos, error_message); } diff --git a/src/3rdparty/libpng/pngget.c b/src/3rdparty/libpng/pngget.c index 743a6a9bbc..141c393330 100644 --- a/src/3rdparty/libpng/pngget.c +++ b/src/3rdparty/libpng/pngget.c @@ -1,8 +1,8 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.6.17 [March 26, 2015] - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -338,7 +338,7 @@ ppi_from_ppm(png_uint_32 ppm) png_fixed_point result; if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127, 5000) != 0) - return result; + return (png_uint_32)result; /* Overflow. */ return 0; @@ -456,11 +456,11 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr, return (retval); } #endif /* pHYs */ -#endif /* INCH_CONVERSIONS */ +#endif /* INCH_CONVERSIONS */ /* png_get_channels really belongs in here, too, but it's been around longer */ -#endif /* EASY_ACCESS */ +#endif /* EASY_ACCESS */ png_byte PNGAPI @@ -486,7 +486,7 @@ png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr) #ifdef PNG_bKGD_SUPPORTED png_uint_32 PNGAPI png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr, - png_color_16p *background) + png_color_16p *background) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0 && @@ -526,28 +526,28 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr, if (white_x != NULL) *white_x = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.whitex, "cHRM white X"); + info_ptr->colorspace.end_points_xy.whitex, "cHRM white X"); if (white_y != NULL) *white_y = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y"); + info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y"); if (red_x != NULL) *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx, - "cHRM red X"); + "cHRM red X"); if (red_y != NULL) *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy, - "cHRM red Y"); + "cHRM red Y"); if (green_x != NULL) *green_x = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.greenx, "cHRM green X"); + info_ptr->colorspace.end_points_xy.greenx, "cHRM green X"); if (green_y != NULL) *green_y = png_float(png_ptr, - info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y"); + info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y"); if (blue_x != NULL) *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex, - "cHRM blue X"); + "cHRM blue X"); if (blue_y != NULL) *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey, - "cHRM blue Y"); + "cHRM blue Y"); return (PNG_INFO_cHRM); } @@ -556,42 +556,42 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 PNGAPI png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr, - double *red_X, double *red_Y, double *red_Z, double *green_X, - double *green_Y, double *green_Z, double *blue_X, double *blue_Y, - double *blue_Z) + double *red_X, double *red_Y, double *red_Z, double *green_X, + double *green_Y, double *green_Z, double *blue_X, double *blue_Y, + double *blue_Z) { if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) { png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)"); if (red_X != NULL) *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X, - "cHRM red X"); + "cHRM red X"); if (red_Y != NULL) *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y, - "cHRM red Y"); + "cHRM red Y"); if (red_Z != NULL) *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z, - "cHRM red Z"); + "cHRM red Z"); if (green_X != NULL) *green_X = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X"); + info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X"); if (green_Y != NULL) *green_Y = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y"); + info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y"); if (green_Z != NULL) *green_Z = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z"); + info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z"); if (blue_X != NULL) *blue_X = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X"); + info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X"); if (blue_Y != NULL) *blue_Y = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y"); + info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y"); if (blue_Z != NULL) *blue_Z = png_float(png_ptr, - info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z"); + info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z"); return (PNG_INFO_cHRM); } @@ -681,8 +681,8 @@ png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, png_debug1(1, "in %s retrieval function", "gAMA"); if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && - file_gamma != NULL) + (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 && + file_gamma != NULL) { *file_gamma = info_ptr->colorspace.gamma; return (PNG_INFO_gAMA); @@ -704,7 +704,7 @@ png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr, file_gamma != NULL) { *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma, - "png_get_gAMA"); + "png_get_gAMA"); return (PNG_INFO_gAMA); } @@ -901,7 +901,7 @@ png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, */ *width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width"); *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height), - "sCAL height"); + "sCAL height"); return (PNG_INFO_sCAL); } @@ -1142,19 +1142,19 @@ png_get_compression_buffer_size(png_const_structrp png_ptr) return 0; #ifdef PNG_WRITE_SUPPORTED - if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) + if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) #endif { #ifdef PNG_SEQUENTIAL_READ_SUPPORTED - return png_ptr->IDAT_read_size; + return png_ptr->IDAT_read_size; #else - return PNG_IDAT_READ_SIZE; + return PNG_IDAT_READ_SIZE; #endif } #ifdef PNG_WRITE_SUPPORTED - else - return png_ptr->zbuffer_size; + else + return png_ptr->zbuffer_size; #endif } diff --git a/src/3rdparty/libpng/pnginfo.h b/src/3rdparty/libpng/pnginfo.h index 4bd264b869..361ed8be70 100644 --- a/src/3rdparty/libpng/pnginfo.h +++ b/src/3rdparty/libpng/pnginfo.h @@ -2,7 +2,7 @@ /* pnginfo.h - header file for PNG reference library * * Last changed in libpng 1.6.1 [March 28, 2013] - * Copyright (c) 1998-2013 Glenn Randers-Pehrson + * Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * diff --git a/src/3rdparty/libpng/pngmem.c b/src/3rdparty/libpng/pngmem.c index 45ac5579b2..ff3ef7e88c 100644 --- a/src/3rdparty/libpng/pngmem.c +++ b/src/3rdparty/libpng/pngmem.c @@ -1,8 +1,8 @@ /* pngmem.c - stub functions for memory allocation * - * Last changed in libpng 1.6.15 [November 20, 2014] - * Copyright (c) 1998-2014 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -66,7 +66,7 @@ png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) */ PNG_FUNCTION(png_voidp /* PRIVATE */, png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size), - PNG_ALLOCATED) + PNG_ALLOCATED) { /* Moved to png_malloc_base from png_malloc_default in 1.6.0; the DOS * allocators have also been removed in 1.6.0, so any 16-bit system now has @@ -107,9 +107,9 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size), */ static png_voidp png_malloc_array_checked(png_const_structrp png_ptr, int nelements, - size_t element_size) + size_t element_size) { - png_alloc_size_t req = nelements; /* known to be > 0 */ + png_alloc_size_t req = (png_alloc_size_t)nelements; /* known to be > 0 */ if (req <= PNG_SIZE_MAX/element_size) return png_malloc_base(png_ptr, req * element_size); @@ -120,7 +120,7 @@ png_malloc_array_checked(png_const_structrp png_ptr, int nelements, PNG_FUNCTION(png_voidp /* PRIVATE */, png_malloc_array,(png_const_structrp png_ptr, int nelements, - size_t element_size),PNG_ALLOCATED) + size_t element_size),PNG_ALLOCATED) { if (nelements <= 0 || element_size == 0) png_error(png_ptr, "internal error: array alloc"); @@ -130,7 +130,7 @@ png_malloc_array,(png_const_structrp png_ptr, int nelements, PNG_FUNCTION(png_voidp /* PRIVATE */, png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array, - int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED) + int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED) { /* These are internal errors: */ if (add_elements <= 0 || element_size == 0 || old_elements < 0 || @@ -143,7 +143,7 @@ png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array, if (add_elements <= INT_MAX - old_elements) { png_voidp new_array = png_malloc_array_checked(png_ptr, - old_elements+add_elements, element_size); + old_elements+add_elements, element_size); if (new_array != NULL) { @@ -154,7 +154,7 @@ png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array, memcpy(new_array, old_array, element_size*(unsigned)old_elements); memset((char*)new_array + element_size*(unsigned)old_elements, 0, - element_size*(unsigned)add_elements); + element_size*(unsigned)add_elements); return new_array; } @@ -187,7 +187,7 @@ png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED) #ifdef PNG_USER_MEM_SUPPORTED PNG_FUNCTION(png_voidp,PNGAPI png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size), - PNG_ALLOCATED PNG_DEPRECATED) + PNG_ALLOCATED PNG_DEPRECATED) { png_voidp ret; @@ -210,7 +210,7 @@ png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size), */ PNG_FUNCTION(png_voidp,PNGAPI png_malloc_warn,(png_const_structrp png_ptr, png_alloc_size_t size), - PNG_ALLOCATED) + PNG_ALLOCATED) { if (png_ptr != NULL) { diff --git a/src/3rdparty/libpng/pngpread.c b/src/3rdparty/libpng/pngpread.c index 89ffc4018f..650ba1e232 100644 --- a/src/3rdparty/libpng/pngpread.c +++ b/src/3rdparty/libpng/pngpread.c @@ -1,8 +1,8 @@ /* pngpread.c - read a png file in push mode * - * Last changed in libpng 1.6.18 [July 23, 2015] - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.24 [August 4, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -77,11 +77,11 @@ png_process_data_pause(png_structrp png_ptr, int save) png_uint_32 PNGAPI png_process_data_skip(png_structrp png_ptr) { - /* TODO: Deprecate and remove this API. - * Somewhere the implementation of this seems to have been lost, - * or abandoned. It was only to support some internal back-door access - * to png_struct) in libpng-1.4.x. - */ +/* TODO: Deprecate and remove this API. + * Somewhere the implementation of this seems to have been lost, + * or abandoned. It was only to support some internal back-door access + * to png_struct) in libpng-1.4.x. + */ png_app_warning(png_ptr, "png_process_data_skip is not implemented in any current version of libpng"); return 0; @@ -210,12 +210,14 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) (png_ptr->mode & PNG_HAVE_PLTE) == 0) png_error(png_ptr, "Missing PLTE before IDAT"); - png_ptr->mode |= PNG_HAVE_IDAT; png_ptr->process_mode = PNG_READ_IDAT_MODE; - if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0) - if (png_ptr->push_length == 0) - return; + if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0) + if (png_ptr->push_length == 0) + return; + + png_ptr->mode |= PNG_HAVE_IDAT; if ((png_ptr->mode & PNG_AFTER_IDAT) != 0) png_benign_error(png_ptr, "Too many IDATs found"); @@ -408,7 +410,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) { PNG_PUSH_SAVE_BUFFER_IF_FULL png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, - PNG_HANDLE_CHUNK_AS_DEFAULT); + PNG_HANDLE_CHUNK_AS_DEFAULT); } png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER; @@ -499,7 +501,10 @@ png_push_save_buffer(png_structrp png_ptr) png_error(png_ptr, "Insufficient memory for save_buffer"); } - memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); + if (old_buffer) + memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size); + else if (png_ptr->save_buffer_size) + png_error(png_ptr, "save_buffer error"); png_free(png_ptr, old_buffer); png_ptr->save_buffer_max = new_max; } @@ -516,7 +521,7 @@ png_push_save_buffer(png_structrp png_ptr) void /* PRIVATE */ png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer, - png_size_t buffer_length) + png_size_t buffer_length) { png_ptr->current_buffer = buffer; png_ptr->current_buffer_size = buffer_length; @@ -619,7 +624,7 @@ png_push_read_IDAT(png_structrp png_ptr) void /* PRIVATE */ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer, - png_size_t buffer_length) + png_size_t buffer_length) { /* The caller checks for a non-zero buffer length. */ if (!(buffer_length > 0) || buffer == NULL) @@ -679,7 +684,12 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer, png_warning(png_ptr, "Truncated compressed data in IDAT"); else - png_error(png_ptr, "Decompression error in IDAT"); + { + if (ret == Z_DATA_ERROR) + png_benign_error(png_ptr, "IDAT: ADLER32 checksum mismatch"); + else + png_error(png_ptr, "Decompression error in IDAT"); + } /* Skip the check on unprocessed input */ return; @@ -777,7 +787,7 @@ png_push_process_row(png_structrp png_ptr) { if (png_ptr->pass < 6) png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, - png_ptr->transformations); + png_ptr->transformations); switch (png_ptr->pass) { @@ -1039,7 +1049,7 @@ png_push_have_row(png_structrp png_ptr, png_bytep row) { if (png_ptr->row_fn != NULL) (*(png_ptr->row_fn))(png_ptr, row, png_ptr->row_number, - (int)png_ptr->pass); + (int)png_ptr->pass); } #ifdef PNG_READ_INTERLACING_SUPPORTED diff --git a/src/3rdparty/libpng/pngpriv.h b/src/3rdparty/libpng/pngpriv.h index c06deee68d..0a12fb67bd 100644 --- a/src/3rdparty/libpng/pngpriv.h +++ b/src/3rdparty/libpng/pngpriv.h @@ -1,8 +1,8 @@ /* pngpriv.h - private declarations for use inside libpng * - * Last changed in libpng 1.6.18 [July 23, 2015] - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -188,6 +188,35 @@ # endif #endif /* PNG_ARM_NEON_OPT > 0 */ +#ifndef PNG_MIPS_MSA_OPT +# if defined(__mips_msa) && (__mips_isa_rev >= 5) && defined(PNG_ALIGNED_MEMORY_SUPPORTED) +# define PNG_MIPS_MSA_OPT 2 +# else +# define PNG_MIPS_MSA_OPT 0 +# endif +#endif + +#if PNG_MIPS_MSA_OPT > 0 +# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_msa +# ifndef PNG_MIPS_MSA_IMPLEMENTATION +# if defined(__mips_msa) +# if defined(__clang__) +# elif defined(__GNUC__) +# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7) +# define PNG_MIPS_MSA_IMPLEMENTATION 2 +# endif /* no GNUC support */ +# endif /* __GNUC__ */ +# else /* !defined __mips_msa */ +# define PNG_MIPS_MSA_IMPLEMENTATION 2 +# endif /* __mips_msa */ +# endif /* !PNG_MIPS_MSA_IMPLEMENTATION */ + +# ifndef PNG_MIPS_MSA_IMPLEMENTATION +# define PNG_MIPS_MSA_IMPLEMENTATION 1 +# endif +#endif /* PNG_MIPS_MSA_OPT > 0 */ + + /* Is this a build of a DLL where compilation of the object modules requires * different preprocessor settings to those required for a simple library? If * so PNG_BUILD_DLL must be set. @@ -431,10 +460,10 @@ # if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) - /* We need to check that hasn't already been included earlier - * as it seems it doesn't agree with , yet we should really use - * if possible. - */ + /* We need to check that hasn't already been included earlier + * as it seems it doesn't agree with , yet we should really use + * if possible. + */ # if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__) # include # endif @@ -442,9 +471,9 @@ # include # endif # if defined(_AMIGA) && defined(__SASC) && defined(_M68881) - /* Amiga SAS/C: We must include builtin FPU functions when compiling using - * MATH=68881 - */ + /* Amiga SAS/C: We must include builtin FPU functions when compiling using + * MATH=68881 + */ # include # endif #endif @@ -518,7 +547,8 @@ /* This implicitly assumes alignment is always to a power of 2. */ #ifdef png_alignof # define png_isaligned(ptr, type)\ - ((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0) + (((type)((const char*)ptr-(const char*)0) & \ + (type)(png_alignof(type)-1)) == 0) #else # define png_isaligned(ptr, type) 0 #endif @@ -535,92 +565,92 @@ * are defined in png.h because they need to be visible to applications * that call png_set_unknown_chunk(). */ -/* #define PNG_HAVE_IHDR 0x01 (defined in png.h) */ -/* #define PNG_HAVE_PLTE 0x02 (defined in png.h) */ -#define PNG_HAVE_IDAT 0x04 -/* #define PNG_AFTER_IDAT 0x08 (defined in png.h) */ -#define PNG_HAVE_IEND 0x10 - /* 0x20 (unused) */ - /* 0x40 (unused) */ - /* 0x80 (unused) */ -#define PNG_HAVE_CHUNK_HEADER 0x100 -#define PNG_WROTE_tIME 0x200 -#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 -#define PNG_BACKGROUND_IS_GRAY 0x800 -#define PNG_HAVE_PNG_SIGNATURE 0x1000 -#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ - /* 0x4000 (unused) */ -#define PNG_IS_READ_STRUCT 0x8000 /* Else is a write struct */ +/* #define PNG_HAVE_IHDR 0x01U (defined in png.h) */ +/* #define PNG_HAVE_PLTE 0x02U (defined in png.h) */ +#define PNG_HAVE_IDAT 0x04U +/* #define PNG_AFTER_IDAT 0x08U (defined in png.h) */ +#define PNG_HAVE_IEND 0x10U + /* 0x20U (unused) */ + /* 0x40U (unused) */ + /* 0x80U (unused) */ +#define PNG_HAVE_CHUNK_HEADER 0x100U +#define PNG_WROTE_tIME 0x200U +#define PNG_WROTE_INFO_BEFORE_PLTE 0x400U +#define PNG_BACKGROUND_IS_GRAY 0x800U +#define PNG_HAVE_PNG_SIGNATURE 0x1000U +#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */ + /* 0x4000U (unused) */ +#define PNG_IS_READ_STRUCT 0x8000U /* Else is a write struct */ /* Flags for the transformations the PNG library does on the image data */ -#define PNG_BGR 0x0001 -#define PNG_INTERLACE 0x0002 -#define PNG_PACK 0x0004 -#define PNG_SHIFT 0x0008 -#define PNG_SWAP_BYTES 0x0010 -#define PNG_INVERT_MONO 0x0020 -#define PNG_QUANTIZE 0x0040 -#define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */ -#define PNG_BACKGROUND_EXPAND 0x0100 -#define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */ -#define PNG_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */ -#define PNG_RGBA 0x0800 -#define PNG_EXPAND 0x1000 -#define PNG_GAMMA 0x2000 -#define PNG_GRAY_TO_RGB 0x4000 -#define PNG_FILLER 0x8000 -#define PNG_PACKSWAP 0x10000 -#define PNG_SWAP_ALPHA 0x20000 -#define PNG_STRIP_ALPHA 0x40000 -#define PNG_INVERT_ALPHA 0x80000 -#define PNG_USER_TRANSFORM 0x100000 -#define PNG_RGB_TO_GRAY_ERR 0x200000 -#define PNG_RGB_TO_GRAY_WARN 0x400000 -#define PNG_RGB_TO_GRAY 0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */ -#define PNG_ENCODE_ALPHA 0x800000 /* Added to libpng-1.5.4 */ -#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */ -#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */ -#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */ - /* 0x8000000 unused */ - /* 0x10000000 unused */ - /* 0x20000000 unused */ - /* 0x40000000 unused */ +#define PNG_BGR 0x0001U +#define PNG_INTERLACE 0x0002U +#define PNG_PACK 0x0004U +#define PNG_SHIFT 0x0008U +#define PNG_SWAP_BYTES 0x0010U +#define PNG_INVERT_MONO 0x0020U +#define PNG_QUANTIZE 0x0040U +#define PNG_COMPOSE 0x0080U /* Was PNG_BACKGROUND */ +#define PNG_BACKGROUND_EXPAND 0x0100U +#define PNG_EXPAND_16 0x0200U /* Added to libpng 1.5.2 */ +#define PNG_16_TO_8 0x0400U /* Becomes 'chop' in 1.5.4 */ +#define PNG_RGBA 0x0800U +#define PNG_EXPAND 0x1000U +#define PNG_GAMMA 0x2000U +#define PNG_GRAY_TO_RGB 0x4000U +#define PNG_FILLER 0x8000U +#define PNG_PACKSWAP 0x10000U +#define PNG_SWAP_ALPHA 0x20000U +#define PNG_STRIP_ALPHA 0x40000U +#define PNG_INVERT_ALPHA 0x80000U +#define PNG_USER_TRANSFORM 0x100000U +#define PNG_RGB_TO_GRAY_ERR 0x200000U +#define PNG_RGB_TO_GRAY_WARN 0x400000U +#define PNG_RGB_TO_GRAY 0x600000U /* two bits, RGB_TO_GRAY_ERR|WARN */ +#define PNG_ENCODE_ALPHA 0x800000U /* Added to libpng-1.5.4 */ +#define PNG_ADD_ALPHA 0x1000000U /* Added to libpng-1.2.7 */ +#define PNG_EXPAND_tRNS 0x2000000U /* Added to libpng-1.2.9 */ +#define PNG_SCALE_16_TO_8 0x4000000U /* Added to libpng-1.5.4 */ + /* 0x8000000U unused */ + /* 0x10000000U unused */ + /* 0x20000000U unused */ + /* 0x40000000U unused */ /* Flags for png_create_struct */ -#define PNG_STRUCT_PNG 0x0001 -#define PNG_STRUCT_INFO 0x0002 +#define PNG_STRUCT_PNG 0x0001U +#define PNG_STRUCT_INFO 0x0002U /* Flags for the png_ptr->flags rather than declaring a byte for each one */ -#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 -#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002 /* Added to libpng-1.6.0 */ - /* 0x0004 unused */ -#define PNG_FLAG_ZSTREAM_ENDED 0x0008 /* Added to libpng-1.6.0 */ - /* 0x0010 unused */ - /* 0x0020 unused */ -#define PNG_FLAG_ROW_INIT 0x0040 -#define PNG_FLAG_FILLER_AFTER 0x0080 -#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100 -#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200 -#define PNG_FLAG_CRC_CRITICAL_USE 0x0400 -#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800 -#define PNG_FLAG_ASSUME_sRGB 0x1000 /* Added to libpng-1.5.4 */ -#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000 /* Added to libpng-1.5.4 */ -#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000 /* Added to libpng-1.5.4 */ -/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000 */ -/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000 */ -#define PNG_FLAG_LIBRARY_MISMATCH 0x20000 -#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000 -#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000 -#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000 /* Added to libpng-1.4.0 */ -#define PNG_FLAG_APP_WARNINGS_WARN 0x200000 /* Added to libpng-1.6.0 */ -#define PNG_FLAG_APP_ERRORS_WARN 0x400000 /* Added to libpng-1.6.0 */ - /* 0x800000 unused */ - /* 0x1000000 unused */ - /* 0x2000000 unused */ - /* 0x4000000 unused */ - /* 0x8000000 unused */ - /* 0x10000000 unused */ - /* 0x20000000 unused */ - /* 0x40000000 unused */ +#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001U +#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002U /* Added to libpng-1.6.0 */ + /* 0x0004U unused */ +#define PNG_FLAG_ZSTREAM_ENDED 0x0008U /* Added to libpng-1.6.0 */ + /* 0x0010U unused */ + /* 0x0020U unused */ +#define PNG_FLAG_ROW_INIT 0x0040U +#define PNG_FLAG_FILLER_AFTER 0x0080U +#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100U +#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200U +#define PNG_FLAG_CRC_CRITICAL_USE 0x0400U +#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800U +#define PNG_FLAG_ASSUME_sRGB 0x1000U /* Added to libpng-1.5.4 */ +#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000U /* Added to libpng-1.5.4 */ +#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000U /* Added to libpng-1.5.4 */ +/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000U */ +/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000U */ +#define PNG_FLAG_LIBRARY_MISMATCH 0x20000U +#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000U +#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000U +#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000U /* Added to libpng-1.4.0 */ +#define PNG_FLAG_APP_WARNINGS_WARN 0x200000U /* Added to libpng-1.6.0 */ +#define PNG_FLAG_APP_ERRORS_WARN 0x400000U /* Added to libpng-1.6.0 */ + /* 0x800000U unused */ + /* 0x1000000U unused */ + /* 0x2000000U unused */ + /* 0x4000000U unused */ + /* 0x8000000U unused */ + /* 0x10000000U unused */ + /* 0x20000000U unused */ + /* 0x40000000U unused */ #define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \ PNG_FLAG_CRC_ANCILLARY_NOWARN) @@ -654,6 +684,24 @@ ((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \ (( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) ) +/* This returns the number of trailing bits in the last byte of a row, 0 if the + * last byte is completely full of pixels. It is, in principle, (pixel_bits x + * width) % 8, but that would overflow for large 'width'. The second macro is + * the same except that it returns the number of unused bits in the last byte; + * (8-TRAILBITS), but 0 when TRAILBITS is 0. + * + * NOTE: these macros are intended to be self-evidently correct and never + * overflow on the assumption that pixel_bits is in the range 0..255. The + * arguments are evaluated only once and they can be signed (e.g. as a result of + * the integral promotions). The result of the expression always has type + * (png_uint_32), however the compiler always knows it is in the range 0..7. + */ +#define PNG_TRAILBITS(pixel_bits, width) \ + (((pixel_bits) * ((width) % (png_uint_32)8)) % 8) + +#define PNG_PADBITS(pixel_bits, width) \ + ((8 - PNG_TRAILBITS(pixel_bits, width)) % 8) + /* PNG_OUT_OF_RANGE returns true if value is outside the range * ideal-delta..ideal+delta. Each argument is evaluated twice. * "ideal" and "delta" should be constants, normally simple @@ -1039,7 +1087,7 @@ PNG_INTERNAL_FUNCTION(void,png_write_sBIT,(png_structrp png_ptr, #ifdef PNG_WRITE_cHRM_SUPPORTED PNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr, const png_xy *xy), PNG_EMPTY); - /* The xy value must have been previously validated */ + /* The xy value must have been previously validated */ #endif #ifdef PNG_WRITE_sRGB_SUPPORTED @@ -1188,6 +1236,7 @@ PNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info, PNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY); +#if PNG_ARM_NEON_OPT > 0 PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop @@ -1202,6 +1251,24 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +#endif + +#if PNG_MIPS_MSA_OPT > 0 +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_msa,(png_row_infop row_info, + png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_msa,(png_row_infop + row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY); +#endif /* Choose the best filter to use and filter the row data */ PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr, @@ -1229,7 +1296,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr), /* Initialize the row buffers, etc. */ PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY); -#if PNG_ZLIB_VERNUM >= 0x1240 +#if ZLIB_VERNUM >= 0x1240 PNG_INTERNAL_FUNCTION(int,png_zlib_inflate,(png_structrp png_ptr, int flush), PNG_EMPTY); # define PNG_INFLATE(pp, flush) png_zlib_inflate(pp, flush) @@ -1427,7 +1494,7 @@ PNG_INTERNAL_FUNCTION(void,png_push_have_info,(png_structrp png_ptr, PNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr, png_inforp info_ptr),PNG_EMPTY); PNG_INTERNAL_FUNCTION(void,png_push_have_row,(png_structrp png_ptr, - png_bytep row),PNG_EMPTY); + png_bytep row),PNG_EMPTY); PNG_INTERNAL_FUNCTION(void,png_push_read_end,(png_structrp png_ptr, png_inforp info_ptr),PNG_EMPTY); PNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr, @@ -1466,13 +1533,13 @@ PNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr, PNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr, png_inforp info_ptr), PNG_EMPTY); - /* Synchronize the info 'valid' flags with the colorspace */ + /* Synchronize the info 'valid' flags with the colorspace */ PNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr, png_inforp info_ptr), PNG_EMPTY); - /* Copy the png_struct colorspace to the info_struct and call the above to - * synchronize the flags. Checks for NULL info_ptr and does nothing. - */ + /* Copy the png_struct colorspace to the info_struct and call the above to + * synchronize the flags. Checks for NULL info_ptr and does nothing. + */ #endif /* Added at libpng version 1.4.0 */ @@ -1506,9 +1573,11 @@ PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr, /* The 'name' is used for information only */ /* Routines for checking parts of an ICC profile. */ +#ifdef PNG_READ_iCCP_SUPPORTED PNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr, png_colorspacerp colorspace, png_const_charp name, png_uint_32 profile_length), PNG_EMPTY); +#endif /* READ_iCCP */ PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr, png_colorspacerp colorspace, png_const_charp name, png_uint_32 profile_length, @@ -1927,10 +1996,20 @@ PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr, * the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in * CFLAGS in place of CPPFLAGS *and* uses symbol prefixing. */ +# if PNG_ARM_NEON_OPT > 0 PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon, (png_structp png_ptr, unsigned int bpp), PNG_EMPTY); #endif +#if PNG_MIPS_MSA_OPT > 0 +PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa, + (png_structp png_ptr, unsigned int bpp), PNG_EMPTY); +#endif +#endif + +PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr, + png_const_charp key, png_bytep new_key), PNG_EMPTY); + /* Maintainer: Put new private prototypes here ^ */ #include "pngdebug.h" diff --git a/src/3rdparty/libpng/pngread.c b/src/3rdparty/libpng/pngread.c index 9cb4d2e41d..106a80588c 100644 --- a/src/3rdparty/libpng/pngread.c +++ b/src/3rdparty/libpng/pngread.c @@ -1,8 +1,8 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.6.17 [March 26, 2015] - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -28,10 +28,10 @@ png_create_read_struct,(png_const_charp user_png_ver, png_voidp error_ptr, { #ifndef PNG_USER_MEM_SUPPORTED png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr, - error_fn, warn_fn, NULL, NULL, NULL); + error_fn, warn_fn, NULL, NULL, NULL); #else return png_create_read_struct_2(user_png_ver, error_ptr, error_fn, - warn_fn, NULL, NULL, NULL); + warn_fn, NULL, NULL, NULL); } /* Alternate create PNG structure for reading, and allocate any memory @@ -43,7 +43,7 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) { png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr, - error_fn, warn_fn, mem_ptr, malloc_fn, free_fn); + error_fn, warn_fn, mem_ptr, malloc_fn, free_fn); #endif /* USER_MEM */ if (png_ptr != NULL) @@ -127,7 +127,10 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr) } else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) + { + png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; png_ptr->mode |= PNG_AFTER_IDAT; + } /* This should be a binary subdivision search or a hash for * matching the chunk name rather than a linear search. @@ -249,7 +252,7 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr) else png_handle_unknown(png_ptr, info_ptr, length, - PNG_HANDLE_CHUNK_AS_DEFAULT); + PNG_HANDLE_CHUNK_AS_DEFAULT); } } #endif /* SEQUENTIAL_READ */ @@ -276,7 +279,7 @@ png_read_update_info(png_structrp png_ptr, png_inforp info_ptr) /* New in 1.6.0 this avoids the bug of doing the initializations twice */ else png_app_error(png_ptr, - "png_read_update_info/png_start_read_image: duplicate call"); + "png_read_update_info/png_start_read_image: duplicate call"); } } @@ -299,7 +302,7 @@ png_start_read_image(png_structrp png_ptr) /* New in 1.6.0 this avoids the bug of doing the initializations twice */ else png_app_error(png_ptr, - "png_start_read_image/png_read_update_info: duplicate call"); + "png_start_read_image/png_read_update_info: duplicate call"); } } #endif /* SEQUENTIAL_READ */ @@ -356,9 +359,9 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1); - png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3); - png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5); + png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1); + png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3); + png_uint_32 s2 = (png_uint_32)(*(rp + 4) << 8) | *(rp + 5); png_uint_32 red = (s0 + s1 + 65536) & 0xffff; png_uint_32 blue = (s2 + s1 + 65536) & 0xffff; *(rp ) = (png_byte)((red >> 8) & 0xff); @@ -537,7 +540,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) { if (png_ptr->row_buf[0] < PNG_FILTER_VALUE_LAST) png_read_filter_row(png_ptr, &row_info, png_ptr->row_buf + 1, - png_ptr->prev_row + 1, png_ptr->row_buf[0]); + png_ptr->prev_row + 1, png_ptr->row_buf[0]); else png_error(png_ptr, "bad adaptive filter value"); } @@ -581,7 +584,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) { if (png_ptr->pass < 6) png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, - png_ptr->transformations); + png_ptr->transformations); if (dsp_row != NULL) png_combine_row(png_ptr, dsp_row, 1/*display*/); @@ -716,7 +719,7 @@ png_read_image(png_structrp png_ptr, png_bytepp image) * but the caller should do it! */ png_warning(png_ptr, "Interlace handling should be turned on when " - "using png_read_image"); + "using png_read_image"); /* Make sure this is set correctly */ png_ptr->num_rows = png_ptr->height; } @@ -776,8 +779,8 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) #ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED /* Report invalid palette index; added at libng-1.5.10 */ if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - png_ptr->num_palette_max > png_ptr->num_palette) - png_benign_error(png_ptr, "Read palette index exceeding num_palette"); + png_ptr->num_palette_max > png_ptr->num_palette) + png_benign_error(png_ptr, "Read palette index exceeding num_palette"); #endif do @@ -785,6 +788,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) png_uint_32 length = png_read_chunk_header(png_ptr); png_uint_32 chunk_name = png_ptr->chunk_name; + if (chunk_name != png_IDAT) + png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; + if (chunk_name == png_IEND) png_handle_IEND(png_ptr, info_ptr, length); @@ -799,9 +805,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) { if (chunk_name == png_IDAT) { - if ((length > 0) || - (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0) - png_benign_error(png_ptr, "Too many IDATs found"); + if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) + || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0) + png_benign_error(png_ptr, ".Too many IDATs found"); } png_handle_unknown(png_ptr, info_ptr, length, keep); if (chunk_name == png_PLTE) @@ -812,10 +818,14 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) else if (chunk_name == png_IDAT) { /* Zero length IDATs are legal after the last IDAT has been - * read, but not after other chunks have been read. + * read, but not after other chunks have been read. 1.6 does not + * always read all the deflate data; specifically it cannot be relied + * upon to read the Adler32 at the end. If it doesn't ignore IDAT + * chunks which are longer than zero as well: */ - if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0) - png_benign_error(png_ptr, "Too many IDATs found"); + if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED)) + || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0) + png_benign_error(png_ptr, "..Too many IDATs found"); png_crc_finish(png_ptr, length); } @@ -909,7 +919,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) else png_handle_unknown(png_ptr, info_ptr, length, - PNG_HANDLE_CHUNK_AS_DEFAULT); + PNG_HANDLE_CHUNK_AS_DEFAULT); } while ((png_ptr->mode & PNG_HAVE_IEND) == 0); } #endif /* SEQUENTIAL_READ */ @@ -1020,8 +1030,7 @@ png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn) #ifdef PNG_INFO_IMAGE_SUPPORTED void PNGAPI png_read_png(png_structrp png_ptr, png_inforp info_ptr, - int transforms, - voidp params) + int transforms, voidp params) { if (png_ptr == NULL || info_ptr == NULL) return; @@ -1297,7 +1306,7 @@ png_image_read_init(png_imagep image) if (info_ptr != NULL) { png_controlp control = png_voidcast(png_controlp, - png_malloc_warn(png_ptr, (sizeof *control))); + png_malloc_warn(png_ptr, (sizeof *control))); if (control != NULL) { @@ -1384,7 +1393,9 @@ png_image_read_header(png_voidp argument) png_structrp png_ptr = image->opaque->png_ptr; png_inforp info_ptr = image->opaque->info_ptr; +#ifdef PNG_BENIGN_ERRORS_SUPPORTED png_set_benign_errors(png_ptr, 1/*warn*/); +#endif png_read_info(png_ptr, info_ptr); /* Do this the fast way; just read directly out of png_struct. */ @@ -1422,7 +1433,7 @@ png_image_read_header(png_voidp argument) break; case PNG_COLOR_TYPE_PALETTE: - cmap_entries = png_ptr->num_palette; + cmap_entries = (png_uint_32)png_ptr->num_palette; break; default: @@ -1460,12 +1471,12 @@ png_image_begin_read_from_stdio(png_imagep image, FILE* file) else return png_image_error(image, - "png_image_begin_read_from_stdio: invalid argument"); + "png_image_begin_read_from_stdio: invalid argument"); } else if (image != NULL) return png_image_error(image, - "png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION"); + "png_image_begin_read_from_stdio: incorrect PNG_IMAGE_VERSION"); return 0; } @@ -1498,12 +1509,12 @@ png_image_begin_read_from_file(png_imagep image, const char *file_name) else return png_image_error(image, - "png_image_begin_read_from_file: invalid argument"); + "png_image_begin_read_from_file: invalid argument"); } else if (image != NULL) return png_image_error(image, - "png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION"); + "png_image_begin_read_from_file: incorrect PNG_IMAGE_VERSION"); return 0; } @@ -1540,7 +1551,7 @@ png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need) } int PNGAPI png_image_begin_read_from_memory(png_imagep image, - png_const_voidp memory, png_size_t size) + png_const_voidp memory, png_size_t size) { if (image != NULL && image->version == PNG_IMAGE_VERSION) { @@ -1563,12 +1574,12 @@ int PNGAPI png_image_begin_read_from_memory(png_imagep image, else return png_image_error(image, - "png_image_begin_read_from_memory: invalid argument"); + "png_image_begin_read_from_memory: invalid argument"); } else if (image != NULL) return png_image_error(image, - "png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION"); + "png_image_begin_read_from_memory: incorrect PNG_IMAGE_VERSION"); return 0; } @@ -1614,12 +1625,12 @@ png_image_skip_unused_chunks(png_structrp png_ptr) * IHDR, PLTE, tRNS, IDAT, and IEND chunks. */ png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_NEVER, - NULL, -1); + NULL, -1); /* But do not ignore image data handling chunks */ png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_AS_DEFAULT, - chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5); - } + chunks_to_process, (int)/*SAFE*/(sizeof chunks_to_process)/5); + } } # define PNG_SKIP_CHUNKS(p) png_image_skip_unused_chunks(p) @@ -1686,7 +1697,7 @@ decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding) #ifdef __GNUC__ default: png_error(display->image->opaque->png_ptr, - "unexpected encoding (internal error)"); + "unexpected encoding (internal error)"); #endif } @@ -1695,8 +1706,8 @@ decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding) static png_uint_32 png_colormap_compose(png_image_read_control *display, - png_uint_32 foreground, int foreground_encoding, png_uint_32 alpha, - png_uint_32 background, int encoding) + png_uint_32 foreground, int foreground_encoding, png_uint_32 alpha, + png_uint_32 background, int encoding) { /* The file value is composed on the background, the background has the given * encoding and so does the result, the file is encoded with P_FILE and the @@ -1732,14 +1743,14 @@ png_colormap_compose(png_image_read_control *display, */ static void png_create_colormap_entry(png_image_read_control *display, - png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue, - png_uint_32 alpha, int encoding) + png_uint_32 ip, png_uint_32 red, png_uint_32 green, png_uint_32 blue, + png_uint_32 alpha, int encoding) { png_imagep image = display->image; const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ? - P_LINEAR : P_sRGB; + P_LINEAR : P_sRGB; const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 && - (red != green || green != blue); + (red != green || green != blue); if (ip > 255) png_error(image->opaque->png_ptr, "color-map index out of range"); @@ -1957,7 +1968,7 @@ make_gray_file_colormap(png_image_read_control *display) for (i=0; i<256; ++i) png_create_colormap_entry(display, i, i, i, i, 255, P_FILE); - return i; + return (int)i; } static int @@ -1968,7 +1979,7 @@ make_gray_colormap(png_image_read_control *display) for (i=0; i<256; ++i) png_create_colormap_entry(display, i, i, i, i, 255, P_sRGB); - return i; + return (int)i; } #define PNG_GRAY_COLORMAP_ENTRIES 256 @@ -2019,10 +2030,10 @@ make_ga_colormap(png_image_read_control *display) for (g=0; g<6; ++g) png_create_colormap_entry(display, i++, g*51, g*51, g*51, a*51, - P_sRGB); + P_sRGB); } - return i; + return (int)i; } #define PNG_GA_COLORMAP_ENTRIES 256 @@ -2043,11 +2054,11 @@ make_rgb_colormap(png_image_read_control *display) for (b=0; b<6; ++b) png_create_colormap_entry(display, i++, r*51, g*51, b*51, 255, - P_sRGB); + P_sRGB); } } - return i; + return (int)i; } #define PNG_RGB_COLORMAP_ENTRIES 216 @@ -2095,7 +2106,7 @@ png_image_read_colormap(png_voidp argument) else if (display->background == NULL /* no way to remove it */) png_error(png_ptr, - "a background color must be supplied to remove alpha/transparency"); + "background color must be supplied to remove alpha/transparency"); /* Get a copy of the background color (this avoids repeating the checks * below.) The encoding is 8-bit sRGB or 16-bit linear, depending on the @@ -2190,7 +2201,7 @@ png_image_read_colormap(png_voidp argument) */ if (i != trans) png_create_colormap_entry(display, i, val, val, val, 255, - P_FILE/*8-bit with file gamma*/); + P_FILE/*8-bit with file gamma*/); /* Else this entry is transparent. The colors don't matter if * there is an alpha channel (back_alpha == 0), but it does no @@ -2202,7 +2213,7 @@ png_image_read_colormap(png_voidp argument) */ else png_create_colormap_entry(display, i, back_r, back_g, back_b, - back_alpha, output_encoding); + back_alpha, output_encoding); } /* We need libpng to preserve the original encoding. */ @@ -2240,7 +2251,7 @@ png_image_read_colormap(png_voidp argument) if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) png_error(png_ptr, "gray[16] color-map: too few entries"); - cmap_entries = make_gray_colormap(display); + cmap_entries = (unsigned int)make_gray_colormap(display); if (png_ptr->num_trans > 0) { @@ -2267,7 +2278,7 @@ png_image_read_colormap(png_voidp argument) * matches. */ png_create_colormap_entry(display, gray, back_g, back_g, - back_g, 65535, P_LINEAR); + back_g, 65535, P_LINEAR); } /* The background passed to libpng, however, must be the @@ -2281,8 +2292,8 @@ png_image_read_colormap(png_voidp argument) * doesn't. */ png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); output_processing = PNG_CMAP_NONE; break; @@ -2312,7 +2323,7 @@ png_image_read_colormap(png_voidp argument) * background color at full precision. */ png_create_colormap_entry(display, 254, back_r, back_g, back_b, - back_alpha, output_encoding); + back_alpha, output_encoding); } else @@ -2338,7 +2349,7 @@ png_image_read_colormap(png_voidp argument) if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) png_error(png_ptr, "gray+alpha color-map: too few entries"); - cmap_entries = make_ga_colormap(display); + cmap_entries = (unsigned int)make_ga_colormap(display); background_index = PNG_CMAP_GA_BACKGROUND; output_processing = PNG_CMAP_GA; @@ -2372,7 +2383,7 @@ png_image_read_colormap(png_voidp argument) if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) png_error(png_ptr, "gray-alpha color-map: too few entries"); - cmap_entries = make_gray_colormap(display); + cmap_entries = (unsigned int)make_gray_colormap(display); if (output_encoding == P_LINEAR) { @@ -2380,7 +2391,7 @@ png_image_read_colormap(png_voidp argument) /* And make sure the corresponding palette entry matches. */ png_create_colormap_entry(display, gray, back_g, back_g, - back_g, 65535, P_LINEAR); + back_g, 65535, P_LINEAR); } /* The background passed to libpng, however, must be the sRGB @@ -2390,8 +2401,8 @@ png_image_read_colormap(png_voidp argument) c.gray = c.red = c.green = c.blue = (png_uint_16)gray; png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); output_processing = PNG_CMAP_NONE; } @@ -2411,7 +2422,7 @@ png_image_read_colormap(png_voidp argument) { png_uint_32 gray = (i * 256 + 115) / 231; png_create_colormap_entry(display, i++, gray, gray, gray, - 255, P_sRGB); + 255, P_sRGB); } /* NOTE: this preserves the full precision of the application @@ -2420,13 +2431,13 @@ png_image_read_colormap(png_voidp argument) background_index = i; png_create_colormap_entry(display, i++, back_r, back_g, back_b, #ifdef __COVERITY__ - /* Coverity claims that output_encoding cannot be 2 (P_LINEAR) - * here. - */ 255U, + /* Coverity claims that output_encoding + * cannot be 2 (P_LINEAR) here. + */ 255U, #else - output_encoding == P_LINEAR ? 65535U : 255U, + output_encoding == P_LINEAR ? 65535U : 255U, #endif - output_encoding); + output_encoding); /* For non-opaque input composite on the sRGB background - this * requires inverting the encoding for each component. The input @@ -2464,9 +2475,9 @@ png_image_read_colormap(png_voidp argument) png_uint_32 gray = png_sRGB_table[g*51] * alpha; png_create_colormap_entry(display, i++, - PNG_sRGB_FROM_LINEAR(gray + back_rx), - PNG_sRGB_FROM_LINEAR(gray + back_gx), - PNG_sRGB_FROM_LINEAR(gray + back_bx), 255, P_sRGB); + PNG_sRGB_FROM_LINEAR(gray + back_rx), + PNG_sRGB_FROM_LINEAR(gray + back_gx), + PNG_sRGB_FROM_LINEAR(gray + back_bx), 255, P_sRGB); } } @@ -2492,7 +2503,7 @@ png_image_read_colormap(png_voidp argument) * png_set_tRNS_to_alpha before png_set_background_fixed. */ png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, -1, - -1); + -1); data_encoding = P_sRGB; /* The output will now be one or two 8-bit gray or gray+alpha @@ -2511,7 +2522,7 @@ png_image_read_colormap(png_voidp argument) if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) png_error(png_ptr, "rgb[ga] color-map: too few entries"); - cmap_entries = make_ga_colormap(display); + cmap_entries = (unsigned int)make_ga_colormap(display); background_index = PNG_CMAP_GA_BACKGROUND; output_processing = PNG_CMAP_GA; } @@ -2537,12 +2548,12 @@ png_image_read_colormap(png_voidp argument) png_ptr->num_trans > 0) && png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0) { - cmap_entries = make_gray_file_colormap(display); + cmap_entries = (unsigned int)make_gray_file_colormap(display); data_encoding = P_FILE; } else - cmap_entries = make_gray_colormap(display); + cmap_entries = (unsigned int)make_gray_colormap(display); /* But if the input has alpha or transparency it must be removed */ @@ -2568,13 +2579,13 @@ png_image_read_colormap(png_voidp argument) gray = png_sRGB_table[gray]; /* now P_LINEAR */ gray = PNG_DIV257(png_gamma_16bit_correct(gray, - png_ptr->colorspace.gamma)); /* now P_FILE */ + png_ptr->colorspace.gamma)); /* now P_FILE */ /* And make sure the corresponding palette entry contains * exactly the required sRGB value. */ png_create_colormap_entry(display, gray, back_g, back_g, - back_g, 0/*unused*/, output_encoding); + back_g, 0/*unused*/, output_encoding); } else if (output_encoding == P_LINEAR) @@ -2599,8 +2610,8 @@ png_image_read_colormap(png_voidp argument) */ expand_tRNS = 1; png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); } output_processing = PNG_CMAP_NONE; @@ -2630,11 +2641,11 @@ png_image_read_colormap(png_voidp argument) if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries) png_error(png_ptr, "rgb+alpha color-map: too few entries"); - cmap_entries = make_rgb_colormap(display); + cmap_entries = (unsigned int)make_rgb_colormap(display); /* Add a transparent entry. */ png_create_colormap_entry(display, cmap_entries, 255, 255, - 255, 0, P_sRGB); + 255, 0, P_sRGB); /* This is stored as the background index for the processing * algorithm. @@ -2655,7 +2666,7 @@ png_image_read_colormap(png_voidp argument) */ for (b=0; b<256; b = (b << 1) | 0x7f) png_create_colormap_entry(display, cmap_entries++, - r, g, b, 128, P_sRGB); + r, g, b, 128, P_sRGB); } } @@ -2679,10 +2690,10 @@ png_image_read_colormap(png_voidp argument) if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries) png_error(png_ptr, "rgb-alpha color-map: too few entries"); - cmap_entries = make_rgb_colormap(display); + cmap_entries = (unsigned int)make_rgb_colormap(display); png_create_colormap_entry(display, cmap_entries, back_r, - back_g, back_b, 0/*unused*/, output_encoding); + back_g, back_b, 0/*unused*/, output_encoding); if (output_encoding == P_LINEAR) { @@ -2704,9 +2715,9 @@ png_image_read_colormap(png_voidp argument) * index. */ if (memcmp((png_const_bytep)display->colormap + - sample_size * cmap_entries, - (png_const_bytep)display->colormap + - sample_size * PNG_RGB_INDEX(r,g,b), + sample_size * cmap_entries, + (png_const_bytep)display->colormap + + sample_size * PNG_RGB_INDEX(r,g,b), sample_size) != 0) { /* The background color must be added. */ @@ -2724,13 +2735,13 @@ png_image_read_colormap(png_voidp argument) */ for (b=0; b<256; b = (b << 1) | 0x7f) png_create_colormap_entry(display, cmap_entries++, - png_colormap_compose(display, r, P_sRGB, 128, - back_r, output_encoding), - png_colormap_compose(display, g, P_sRGB, 128, - back_g, output_encoding), - png_colormap_compose(display, b, P_sRGB, 128, - back_b, output_encoding), - 0/*unused*/, output_encoding); + png_colormap_compose(display, r, P_sRGB, 128, + back_r, output_encoding), + png_colormap_compose(display, g, P_sRGB, 128, + back_g, output_encoding), + png_colormap_compose(display, b, P_sRGB, 128, + back_b, output_encoding), + 0/*unused*/, output_encoding); } } @@ -2748,8 +2759,8 @@ png_image_read_colormap(png_voidp argument) c.blue = (png_uint_16)back_b; png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); output_processing = PNG_CMAP_RGB; } @@ -2764,7 +2775,7 @@ png_image_read_colormap(png_voidp argument) if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries) png_error(png_ptr, "rgb color-map: too few entries"); - cmap_entries = make_rgb_colormap(display); + cmap_entries = (unsigned int)make_rgb_colormap(display); output_processing = PNG_CMAP_RGB; } } @@ -2788,11 +2799,11 @@ png_image_read_colormap(png_voidp argument) output_processing = PNG_CMAP_NONE; data_encoding = P_FILE; /* Don't change from color-map indices */ - cmap_entries = png_ptr->num_palette; + cmap_entries = (unsigned int)png_ptr->num_palette; if (cmap_entries > 256) cmap_entries = 256; - if (cmap_entries > image->colormap_entries) + if (cmap_entries > (unsigned int)image->colormap_entries) png_error(png_ptr, "palette color-map: too few entries"); for (i=0; i < cmap_entries; ++i) @@ -2801,7 +2812,7 @@ png_image_read_colormap(png_voidp argument) { if (trans[i] == 0) png_create_colormap_entry(display, i, back_r, back_g, - back_b, 0, output_encoding); + back_b, 0, output_encoding); else { @@ -2809,22 +2820,22 @@ png_image_read_colormap(png_voidp argument) * on the sRGB color in 'back'. */ png_create_colormap_entry(display, i, - png_colormap_compose(display, colormap[i].red, P_FILE, - trans[i], back_r, output_encoding), - png_colormap_compose(display, colormap[i].green, P_FILE, - trans[i], back_g, output_encoding), - png_colormap_compose(display, colormap[i].blue, P_FILE, - trans[i], back_b, output_encoding), - output_encoding == P_LINEAR ? trans[i] * 257U : - trans[i], - output_encoding); + png_colormap_compose(display, colormap[i].red, + P_FILE, trans[i], back_r, output_encoding), + png_colormap_compose(display, colormap[i].green, + P_FILE, trans[i], back_g, output_encoding), + png_colormap_compose(display, colormap[i].blue, + P_FILE, trans[i], back_b, output_encoding), + output_encoding == P_LINEAR ? trans[i] * 257U : + trans[i], + output_encoding); } } else png_create_colormap_entry(display, i, colormap[i].red, - colormap[i].green, colormap[i].blue, - i < num_trans ? trans[i] : 255U, P_FILE/*8-bit*/); + colormap[i].green, colormap[i].blue, + i < num_trans ? trans[i] : 255U, P_FILE/*8-bit*/); } /* The PNG data may have indices packed in fewer than 8 bits, it @@ -2904,7 +2915,7 @@ png_image_read_colormap(png_voidp argument) png_error(png_ptr, "bad background index (internal error)"); } - display->colormap_processing = output_processing; + display->colormap_processing = (int)output_processing; return 1/*ok*/; } @@ -2914,7 +2925,7 @@ static int png_image_read_and_map(png_voidp argument) { png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); + argument); png_imagep image = display->image; png_structrp png_ptr = image->opaque->png_ptr; int passes; @@ -3051,7 +3062,7 @@ png_image_read_and_map(png_voidp argument) if (alpha >= 196) *outrow = PNG_RGB_INDEX(inrow[0], inrow[1], - inrow[2]); + inrow[2]); else if (alpha < 64) *outrow = PNG_CMAP_RGB_ALPHA_BACKGROUND; @@ -3103,7 +3114,7 @@ static int png_image_read_colormapped(png_voidp argument) { png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); + argument); png_imagep image = display->image; png_controlp control = image->opaque; png_structrp png_ptr = control->png_ptr; @@ -3213,14 +3224,14 @@ png_image_read_colormapped(png_voidp argument) else { - png_alloc_size_t row_bytes = display->row_bytes; + png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes; while (--passes >= 0) { png_uint_32 y = image->height; png_bytep row = png_voidcast(png_bytep, display->first_row); - while (y-- > 0) + for (; y > 0; --y) { png_read_row(png_ptr, row, NULL); row += row_bytes; @@ -3236,7 +3247,7 @@ static int png_image_read_composite(png_voidp argument) { png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); + argument); png_imagep image = display->image; png_structrp png_ptr = image->opaque->png_ptr; int passes; @@ -3363,7 +3374,7 @@ static int png_image_read_background(png_voidp argument) { png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); + argument); png_imagep image = display->image; png_structrp png_ptr = image->opaque->png_ptr; png_inforp info_ptr = image->opaque->info_ptr; @@ -3423,8 +3434,7 @@ png_image_read_background(png_voidp argument) for (pass = 0; pass < passes; ++pass) { - png_bytep row = png_voidcast(png_bytep, - display->first_row); + png_bytep row = png_voidcast(png_bytep, display->first_row); unsigned int startx, stepx, stepy; png_uint_32 y; @@ -3452,7 +3462,7 @@ png_image_read_background(png_voidp argument) for (; ylocal_row); + display->local_row); png_bytep outrow = first_row + y * step_row; png_const_bytep end_row = outrow + width; @@ -3497,7 +3507,7 @@ png_image_read_background(png_voidp argument) for (; ylocal_row); + display->local_row); png_bytep outrow = first_row + y * step_row; png_const_bytep end_row = outrow + width; @@ -3544,13 +3554,14 @@ png_image_read_background(png_voidp argument) */ { png_uint_16p first_row = png_voidcast(png_uint_16p, - display->first_row); + display->first_row); /* The division by two is safe because the caller passed in a * stride which was multiplied by 2 (below) to get row_bytes. */ ptrdiff_t step_row = display->row_bytes / 2; - int preserve_alpha = (image->format & PNG_FORMAT_FLAG_ALPHA) != 0; - unsigned int outchannels = 1+preserve_alpha; + unsigned int preserve_alpha = (image->format & + PNG_FORMAT_FLAG_ALPHA) != 0; + unsigned int outchannels = 1U+preserve_alpha; int swap_alpha = 0; # ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED @@ -3594,7 +3605,7 @@ png_image_read_background(png_voidp argument) /* Read the row, which is packed: */ png_read_row(png_ptr, png_voidcast(png_bytep, - display->local_row), NULL); + display->local_row), NULL); inrow = png_voidcast(png_const_uint_16p, display->local_row); /* Now do the pre-multiplication on each pixel in this row. @@ -3643,7 +3654,7 @@ static int png_image_read_direct(png_voidp argument) { png_image_read_control *display = png_voidcast(png_image_read_control*, - argument); + argument); png_imagep image = display->image; png_structrp png_ptr = image->opaque->png_ptr; png_inforp info_ptr = image->opaque->info_ptr; @@ -3694,7 +3705,7 @@ png_image_read_direct(png_voidp argument) do_local_background = 1/*maybe*/; png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, - PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT); + PNG_RGB_TO_GRAY_DEFAULT, PNG_RGB_TO_GRAY_DEFAULT); } change &= ~PNG_FORMAT_FLAG_COLOR; @@ -3753,7 +3764,7 @@ png_image_read_direct(png_voidp argument) * final value. */ if (png_muldiv(>est, output_gamma, png_ptr->colorspace.gamma, - PNG_FP_1) != 0 && png_gamma_significant(gtest) == 0) + PNG_FP_1) != 0 && png_gamma_significant(gtest) == 0) do_local_background = 0; else if (mode == PNG_ALPHA_STANDARD) @@ -3816,8 +3827,8 @@ png_image_read_direct(png_voidp argument) * pixels. */ png_set_background_fixed(png_ptr, &c, - PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, - 0/*gamma: not used*/); + PNG_BACKGROUND_GAMMA_SCREEN, 0/*need_expand*/, + 0/*gamma: not used*/); } else /* compose on row: implemented below. */ @@ -3848,16 +3859,16 @@ png_image_read_direct(png_voidp argument) else filler = 255; -# ifdef PNG_FORMAT_AFIRST_SUPPORTED - if ((format & PNG_FORMAT_FLAG_AFIRST) != 0) - { - where = PNG_FILLER_BEFORE; - change &= ~PNG_FORMAT_FLAG_AFIRST; - } +#ifdef PNG_FORMAT_AFIRST_SUPPORTED + if ((format & PNG_FORMAT_FLAG_AFIRST) != 0) + { + where = PNG_FILLER_BEFORE; + change &= ~PNG_FORMAT_FLAG_AFIRST; + } - else -# endif - where = PNG_FILLER_AFTER; + else +#endif + where = PNG_FILLER_AFTER; png_set_add_alpha(png_ptr, filler, where); } @@ -3965,12 +3976,12 @@ png_image_read_direct(png_voidp argument) if (info_ptr->bit_depth == 16) info_format |= PNG_FORMAT_FLAG_LINEAR; -# ifdef PNG_FORMAT_BGR_SUPPORTED - if ((png_ptr->transformations & PNG_BGR) != 0) - info_format |= PNG_FORMAT_FLAG_BGR; -# endif +#ifdef PNG_FORMAT_BGR_SUPPORTED + if ((png_ptr->transformations & PNG_BGR) != 0) + info_format |= PNG_FORMAT_FLAG_BGR; +#endif -# ifdef PNG_FORMAT_AFIRST_SUPPORTED +#ifdef PNG_FORMAT_AFIRST_SUPPORTED if (do_local_background == 2) { if ((format & PNG_FORMAT_FLAG_AFIRST) != 0) @@ -4047,14 +4058,14 @@ png_image_read_direct(png_voidp argument) else { - png_alloc_size_t row_bytes = display->row_bytes; + png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes; while (--passes >= 0) { png_uint_32 y = image->height; png_bytep row = png_voidcast(png_bytep, display->first_row); - while (y-- > 0) + for (; y > 0; --y) { png_read_row(png_ptr, row, NULL); row += row_bytes; @@ -4067,67 +4078,117 @@ png_image_read_direct(png_voidp argument) int PNGAPI png_image_finish_read(png_imagep image, png_const_colorp background, - void *buffer, png_int_32 row_stride, void *colormap) + void *buffer, png_int_32 row_stride, void *colormap) { if (image != NULL && image->version == PNG_IMAGE_VERSION) { - png_uint_32 check; + /* Check for row_stride overflow. This check is not performed on the + * original PNG format because it may not occur in the output PNG format + * and libpng deals with the issues of reading the original. + */ + const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format); - if (row_stride == 0) - row_stride = PNG_IMAGE_ROW_STRIDE(*image); + /* The following checks just the 'row_stride' calculation to ensure it + * fits in a signed 32-bit value. Because channels/components can be + * either 1 or 2 bytes in size the length of a row can still overflow 32 + * bits; this is just to verify that the 'row_stride' argument can be + * represented. + */ + if (image->width <= 0x7fffffffU/channels) /* no overflow */ + { + png_uint_32 check; + const png_uint_32 png_row_stride = image->width * channels; - if (row_stride < 0) - check = -row_stride; + if (row_stride == 0) + row_stride = (png_int_32)/*SAFE*/png_row_stride; - else - check = row_stride; + if (row_stride < 0) + check = (png_uint_32)(-row_stride); - if (image->opaque != NULL && buffer != NULL && - check >= PNG_IMAGE_ROW_STRIDE(*image)) - { - if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 || - (image->colormap_entries > 0 && colormap != NULL)) + else + check = (png_uint_32)row_stride; + + /* This verifies 'check', the absolute value of the actual stride + * passed in and detects overflow in the application calculation (i.e. + * if the app did actually pass in a non-zero 'row_stride'. + */ + if (image->opaque != NULL && buffer != NULL && check >= png_row_stride) { - int result; - png_image_read_control display; - - memset(&display, 0, (sizeof display)); - display.image = image; - display.buffer = buffer; - display.row_stride = row_stride; - display.colormap = colormap; - display.background = background; - display.local_row = NULL; - - /* Choose the correct 'end' routine; for the color-map case all the - * setup has already been done. + /* Now check for overflow of the image buffer calculation; this + * limits the whole image size to 32 bits for API compatibility with + * the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro. + * + * The PNG_IMAGE_BUFFER_SIZE macro is: + * + * (PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)*height*(row_stride)) + * + * And the component size is always 1 or 2, so make sure that the + * number of *bytes* that the application is saying are available + * does actually fit into a 32-bit number. + * + * NOTE: this will be changed in 1.7 because PNG_IMAGE_BUFFER_SIZE + * will be changed to use png_alloc_size_t; bigger images can be + * accomodated on 64-bit systems. */ - if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0) - result = - png_safe_execute(image, png_image_read_colormap, &display) && - png_safe_execute(image, png_image_read_colormapped, &display); + if (image->height <= + 0xffffffffU/PNG_IMAGE_PIXEL_COMPONENT_SIZE(image->format)/check) + { + if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 || + (image->colormap_entries > 0 && colormap != NULL)) + { + int result; + png_image_read_control display; + + memset(&display, 0, (sizeof display)); + display.image = image; + display.buffer = buffer; + display.row_stride = row_stride; + display.colormap = colormap; + display.background = background; + display.local_row = NULL; + + /* Choose the correct 'end' routine; for the color-map case + * all the setup has already been done. + */ + if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0) + result = + png_safe_execute(image, + png_image_read_colormap, &display) && + png_safe_execute(image, + png_image_read_colormapped, &display); - else - result = - png_safe_execute(image, png_image_read_direct, &display); + else + result = + png_safe_execute(image, + png_image_read_direct, &display); - png_image_free(image); - return result; + png_image_free(image); + return result; + } + + else + return png_image_error(image, + "png_image_finish_read[color-map]: no color-map"); + } + + else + return png_image_error(image, + "png_image_finish_read: image too large"); } else return png_image_error(image, - "png_image_finish_read[color-map]: no color-map"); + "png_image_finish_read: invalid argument"); } else return png_image_error(image, - "png_image_finish_read: invalid argument"); + "png_image_finish_read: row_stride too large"); } else if (image != NULL) return png_image_error(image, - "png_image_finish_read: damaged PNG_IMAGE_VERSION"); + "png_image_finish_read: damaged PNG_IMAGE_VERSION"); return 0; } diff --git a/src/3rdparty/libpng/pngrio.c b/src/3rdparty/libpng/pngrio.c index 38f7fd49d6..7e26e855ca 100644 --- a/src/3rdparty/libpng/pngrio.c +++ b/src/3rdparty/libpng/pngrio.c @@ -1,8 +1,8 @@ /* pngrio.c - functions for data input * - * Last changed in libpng 1.6.17 [March 26, 2015] - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.24 [August 4, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -85,7 +85,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) */ void PNGAPI png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr, - png_rw_ptr read_data_fn) + png_rw_ptr read_data_fn) { if (png_ptr == NULL) return; diff --git a/src/3rdparty/libpng/pngrtran.c b/src/3rdparty/libpng/pngrtran.c index f129ef129c..0b4f4f9068 100644 --- a/src/3rdparty/libpng/pngrtran.c +++ b/src/3rdparty/libpng/pngrtran.c @@ -1,8 +1,8 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.6.19 [November 12, 2015] - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.24 [August 4, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -48,7 +48,7 @@ png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action) case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */ png_warning(png_ptr, - "Can't discard critical data on CRC error"); + "Can't discard critical data on CRC error"); case PNG_CRC_ERROR_QUIT: /* Error/quit */ case PNG_CRC_DEFAULT: @@ -101,7 +101,7 @@ png_rtran_ok(png_structrp png_ptr, int need_IHDR) { if ((png_ptr->flags & PNG_FLAG_ROW_INIT) != 0) png_app_error(png_ptr, - "invalid after png_start_read_image or png_read_update_info"); + "invalid after png_start_read_image or png_read_update_info"); else if (need_IHDR && (png_ptr->mode & PNG_HAVE_IHDR) == 0) png_app_error(png_ptr, "invalid before the PNG header has been read"); @@ -159,7 +159,7 @@ png_set_background(png_structrp png_ptr, png_set_background_fixed(png_ptr, background_color, background_gamma_code, need_expand, png_fixed(png_ptr, background_gamma, "png_set_background")); } -# endif /* FLOATING_POINT */ +# endif /* FLOATING_POINT */ #endif /* READ_BACKGROUND */ /* Scale 16-bit depth files to 8-bit depth. If both of these are set then the @@ -209,7 +209,7 @@ png_set_strip_alpha(png_structrp png_ptr) #if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED) static png_fixed_point translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma, - int is_screen) + int is_screen) { /* Check for flag values. The main reason for having the old Mac value as a * flag is that it is pretty near impossible to work out what the correct @@ -273,7 +273,7 @@ convert_gamma_value(png_structrp png_ptr, double output_gamma) #ifdef PNG_READ_ALPHA_MODE_SUPPORTED void PNGFAPI png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, - png_fixed_point output_gamma) + png_fixed_point output_gamma) { int compose = 0; png_fixed_point file_gamma; @@ -289,9 +289,12 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, * is expected to be 1 or greater, but this range test allows for some * viewing correction values. The intent is to weed out users of this API * who use the inverse of the gamma value accidentally! Since some of these - * values are reasonable this may have to be changed. + * values are reasonable this may have to be changed: + * + * 1.6.x: changed from 0.07..3 to 0.01..100 (to accomodate the optimal 16-bit + * gamma of 36, and its reciprocal.) */ - if (output_gamma < 70000 || output_gamma > 300000) + if (output_gamma < 1000 || output_gamma > 10000000) png_error(png_ptr, "output gamma out of expected range"); /* The default file gamma is the inverse of the output gamma; the output @@ -374,7 +377,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, if ((png_ptr->transformations & PNG_COMPOSE) != 0) png_error(png_ptr, - "conflicting calls to set alpha mode and background"); + "conflicting calls to set alpha mode and background"); png_ptr->transformations |= PNG_COMPOSE; } @@ -385,7 +388,7 @@ void PNGAPI png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma) { png_set_alpha_mode_fixed(png_ptr, mode, convert_gamma_value(png_ptr, - output_gamma)); + output_gamma)); } # endif #endif @@ -426,7 +429,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, int i; png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * (sizeof (png_byte)))); + (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte)))); for (i = 0; i < num_palette; i++) png_ptr->quantize_index[i] = (png_byte)i; } @@ -443,7 +446,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, /* Initialize an array to sort colors */ png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * (sizeof (png_byte)))); + (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte)))); /* Initialize the quantize_sort array */ for (i = 0; i < num_palette; i++) @@ -577,9 +580,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, /* Initialize palette index arrays */ png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * (sizeof (png_byte)))); + (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte)))); png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * (sizeof (png_byte)))); + (png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte)))); /* Initialize the sort array */ for (i = 0; i < num_palette; i++) @@ -799,7 +802,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, #ifdef PNG_READ_GAMMA_SUPPORTED void PNGFAPI png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma, - png_fixed_point file_gamma) + png_fixed_point file_gamma) { png_debug(1, "in png_set_gamma_fixed"); @@ -841,7 +844,7 @@ void PNGAPI png_set_gamma(png_structrp png_ptr, double scrn_gamma, double file_gamma) { png_set_gamma_fixed(png_ptr, convert_gamma_value(png_ptr, scrn_gamma), - convert_gamma_value(png_ptr, file_gamma)); + convert_gamma_value(png_ptr, file_gamma)); } # endif /* FLOATING_POINT */ #endif /* READ_GAMMA */ @@ -987,7 +990,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, * that it just worked and get a memory overwrite. */ png_error(png_ptr, - "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED"); + "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED"); /* png_ptr->transformations &= ~PNG_RGB_TO_GRAY; */ } @@ -1014,7 +1017,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, { if (red >= 0 && green >= 0) png_app_warning(png_ptr, - "ignoring out of range rgb_to_gray coefficients"); + "ignoring out of range rgb_to_gray coefficients"); /* Use the defaults, from the cHRM chunk if set, else the historical * values which are close to the sRGB/HDTV/ITU-Rec 709 values. See @@ -1023,7 +1026,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, * something has already provided a default. */ if (png_ptr->rgb_to_gray_red_coeff == 0 && - png_ptr->rgb_to_gray_green_coeff == 0) + png_ptr->rgb_to_gray_green_coeff == 0) { png_ptr->rgb_to_gray_red_coeff = 6968; png_ptr->rgb_to_gray_green_coeff = 23434; @@ -1040,10 +1043,10 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, void PNGAPI png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red, - double green) + double green) { png_set_rgb_to_gray_fixed(png_ptr, error_action, - png_fixed(png_ptr, red, "rgb to gray red coefficient"), + png_fixed(png_ptr, red, "rgb to gray red coefficient"), png_fixed(png_ptr, green, "rgb to gray green coefficient")); } #endif /* FLOATING POINT */ @@ -1300,7 +1303,7 @@ png_init_read_transformations(png_structrp png_ptr) { if (png_ptr->screen_gamma != 0) /* screen set too */ gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma, - png_ptr->screen_gamma); + png_ptr->screen_gamma); else /* Assume the output matches the input; a long time default behavior @@ -1581,7 +1584,7 @@ png_init_read_transformations(png_structrp png_ptr) */ if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0) png_warning(png_ptr, - "libpng does not support gamma+background+rgb_to_gray"); + "libpng does not support gamma+background+rgb_to_gray"); if ((png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) != 0) { @@ -1617,13 +1620,13 @@ png_init_read_transformations(png_structrp png_ptr) case PNG_BACKGROUND_GAMMA_FILE: g = png_reciprocal(png_ptr->colorspace.gamma); gs = png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma); + png_ptr->screen_gamma); break; case PNG_BACKGROUND_GAMMA_UNIQUE: g = png_reciprocal(png_ptr->background_gamma); gs = png_reciprocal2(png_ptr->background_gamma, - png_ptr->screen_gamma); + png_ptr->screen_gamma); break; default: g = PNG_FP_1; /* back_1 */ @@ -1651,11 +1654,11 @@ png_init_read_transformations(png_structrp png_ptr) if (png_gamma_significant(g) != 0) { back_1.red = png_gamma_8bit_correct(png_ptr->background.red, - g); + g); back_1.green = png_gamma_8bit_correct( - png_ptr->background.green, g); + png_ptr->background.green, g); back_1.blue = png_gamma_8bit_correct(png_ptr->background.blue, - g); + g); } else @@ -1726,7 +1729,7 @@ png_init_read_transformations(png_structrp png_ptr) case PNG_BACKGROUND_GAMMA_FILE: g = png_reciprocal(png_ptr->colorspace.gamma); gs = png_reciprocal2(png_ptr->colorspace.gamma, - png_ptr->screen_gamma); + png_ptr->screen_gamma); break; case PNG_BACKGROUND_GAMMA_UNIQUE: @@ -1912,7 +1915,7 @@ png_init_read_transformations(png_structrp png_ptr) png_ptr->palette[i].blue = (png_byte)component; } } -#endif /* READ_SHIFT */ +#endif /* READ_SHIFT */ } /* Modify the info structure to reflect the transformations. The @@ -2147,7 +2150,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row) { png_bytep sp = row + (png_size_t)((row_width - 1) >> 3); png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07); + png_uint_32 shift = 7U - ((row_width + 7U) & 0x07); for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x01); @@ -2171,7 +2174,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row) png_bytep sp = row + (png_size_t)((row_width - 1) >> 2); png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1); + png_uint_32 shift = ((3U - ((row_width + 3U) & 0x03)) << 1); for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x03); @@ -2194,7 +2197,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row) { png_bytep sp = row + (png_size_t)((row_width - 1) >> 1); png_bytep dp = row + (png_size_t)row_width - 1; - png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2); + png_uint_32 shift = ((1U - ((row_width + 1U) & 0x01)) << 2); for (i = 0; i < row_width; i++) { *dp = (png_byte)((*sp >> shift) & 0x0f); @@ -3220,7 +3223,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) == png_ptr->trans_color.gray) { unsigned int tmp = *sp & (0x7f7f >> (7 - shift)); - tmp |= png_ptr->background.gray << shift; + tmp |= + (unsigned int)(png_ptr->background.gray << shift); *sp = (png_byte)(tmp & 0xff); } @@ -3249,7 +3253,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) == png_ptr->trans_color.gray) { unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); - tmp |= png_ptr->background.gray << shift; + tmp |= + (unsigned int)png_ptr->background.gray << shift; *sp = (png_byte)(tmp & 0xff); } @@ -3259,7 +3264,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) unsigned int g = (gamma_table [p | (p << 2) | (p << 4) | (p << 6)] >> 6) & 0x03; unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); - tmp |= g << shift; + tmp |= (unsigned int)(g << shift); *sp = (png_byte)(tmp & 0xff); } @@ -3285,7 +3290,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) == png_ptr->trans_color.gray) { unsigned int tmp = *sp & (0x3f3f >> (6 - shift)); - tmp |= png_ptr->background.gray << shift; + tmp |= + (unsigned int)png_ptr->background.gray << shift; *sp = (png_byte)(tmp & 0xff); } @@ -3315,7 +3321,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) == png_ptr->trans_color.gray) { unsigned int tmp = *sp & (0x0f0f >> (4 - shift)); - tmp |= png_ptr->background.gray << shift; + tmp |= + (unsigned int)(png_ptr->background.gray << shift); *sp = (png_byte)(tmp & 0xff); } @@ -3325,7 +3332,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) unsigned int g = (gamma_table[p | (p << 4)] >> 4) & 0x0f; unsigned int tmp = *sp & (0x0f0f >> (4 - shift)); - tmp |= g << shift; + tmp |= (unsigned int)(g << shift); *sp = (png_byte)(tmp & 0xff); } @@ -3351,7 +3358,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) == png_ptr->trans_color.gray) { unsigned int tmp = *sp & (0x0f0f >> (4 - shift)); - tmp |= png_ptr->background.gray << shift; + tmp |= + (unsigned int)(png_ptr->background.gray << shift); *sp = (png_byte)(tmp & 0xff); } @@ -4192,7 +4200,7 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr) */ static void png_do_expand_palette(png_row_infop row_info, png_bytep row, - png_const_colorp palette, png_const_bytep trans_alpha, int num_trans) + png_const_colorp palette, png_const_bytep trans_alpha, int num_trans) { int shift, value; png_bytep sp, dp; @@ -4499,7 +4507,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, row_info->channels = 2; row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, - row_width); + row_width); } } else if (row_info->color_type == PNG_COLOR_TYPE_RGB && @@ -4759,7 +4767,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA || row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)) png_do_strip_channel(row_info, png_ptr->row_buf + 1, - 0 /* at_start == false, because SWAP_ALPHA happens later */); + 0 /* at_start == false, because SWAP_ALPHA happens later */); #endif #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED diff --git a/src/3rdparty/libpng/pngrutil.c b/src/3rdparty/libpng/pngrutil.c index 6189251352..bee0ea1158 100644 --- a/src/3rdparty/libpng/pngrutil.c +++ b/src/3rdparty/libpng/pngrutil.c @@ -1,8 +1,8 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.6.20 [December 3, 2015] - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.27 [January 5, 2017] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -86,11 +86,11 @@ png_get_int_32)(png_const_bytep buf) { png_uint_32 uval = png_get_uint_32(buf); if ((uval & 0x80000000) == 0) /* non-negative */ - return uval; + return (png_int_32)uval; uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */ if ((uval & 0x80000000) == 0) /* no overflow */ - return -(png_int_32)uval; + return -(png_int_32)uval; /* The following has to be safe; this function only gets called on PNG data * and if we get here that data is invalid. 0 is the most safe value and * if not then an attacker would surely just generate a PNG with 0 instead. @@ -370,11 +370,10 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) */ { int ret; /* zlib return code */ -#if PNG_ZLIB_VERNUM >= 0x1240 +#if ZLIB_VERNUM >= 0x1240 + int window_bits = 0; # if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW) - int window_bits; - if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) == PNG_OPTION_ON) { @@ -384,13 +383,11 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) else { - window_bits = 0; png_ptr->zstream_start = 1; } -# else -# define window_bits 0 # endif -#endif + +#endif /* ZLIB_VERNUM >= 0x1240 */ /* Set this for safety, just in case the previous owner left pointers to * memory allocations. @@ -402,25 +399,32 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0) { -#if PNG_ZLIB_VERNUM < 0x1240 - ret = inflateReset(&png_ptr->zstream); -#else +#if ZLIB_VERNUM >= 0x1240 ret = inflateReset2(&png_ptr->zstream, window_bits); +#else + ret = inflateReset(&png_ptr->zstream); #endif } else { -#if PNG_ZLIB_VERNUM < 0x1240 - ret = inflateInit(&png_ptr->zstream); -#else +#if ZLIB_VERNUM >= 0x1240 ret = inflateInit2(&png_ptr->zstream, window_bits); +#else + ret = inflateInit(&png_ptr->zstream); #endif if (ret == Z_OK) png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; } +#if ZLIB_VERNUM >= 0x1281 && \ + defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32) + if (((png_ptr->options >> PNG_IGNORE_ADLER32) & 3) == PNG_OPTION_ON) + /* Turn off validation of the ADLER32 checksum in IDAT chunks */ + ret = inflateValidate(&png_ptr->zstream, 0); +#endif + if (ret == Z_OK) png_ptr->zowner = owner; @@ -435,7 +439,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner) #endif } -#if PNG_ZLIB_VERNUM >= 0x1240 +#if ZLIB_VERNUM >= 0x1240 /* Handle the start of the inflate stream if we called inflateInit2(strm,0); * in this case some zlib versions skip validation of the CINFO field and, in * certain circumstances, libpng may end up displaying an invalid image, in @@ -461,6 +465,7 @@ png_zlib_inflate(png_structrp png_ptr, int flush) #endif /* Zlib >= 1.2.4 */ #ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED +#if defined(PNG_READ_zTXt_SUPPORTED) || defined (PNG_READ_iTXt_SUPPORTED) /* png_inflate now returns zlib error codes including Z_OK and Z_STREAM_END to * allow the caller to do multiple calls if required. If the 'finish' flag is * set Z_FINISH will be passed to the final inflate() call and Z_STREAM_END must @@ -599,9 +604,9 @@ png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish, */ static int png_decompress_chunk(png_structrp png_ptr, - png_uint_32 chunklength, png_uint_32 prefix_size, - png_alloc_size_t *newlength /* must be initialized to the maximum! */, - int terminate /*add a '\0' to the end of the uncompressed data*/) + png_uint_32 chunklength, png_uint_32 prefix_size, + png_alloc_size_t *newlength /* must be initialized to the maximum! */, + int terminate /*add a '\0' to the end of the uncompressed data*/) { /* TODO: implement different limits for different types of chunk. * @@ -638,8 +643,8 @@ png_decompress_chunk(png_structrp png_ptr, png_uint_32 lzsize = chunklength - prefix_size; ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/, - /* input: */ png_ptr->read_buffer + prefix_size, &lzsize, - /* output: */ NULL, newlength); + /* input: */ png_ptr->read_buffer + prefix_size, &lzsize, + /* output: */ NULL, newlength); if (ret == Z_STREAM_END) { @@ -659,15 +664,15 @@ png_decompress_chunk(png_structrp png_ptr, */ png_alloc_size_t new_size = *newlength; png_alloc_size_t buffer_size = prefix_size + new_size + - (terminate != 0); + (terminate != 0); png_bytep text = png_voidcast(png_bytep, png_malloc_base(png_ptr, - buffer_size)); + buffer_size)); if (text != NULL) { ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/, - png_ptr->read_buffer + prefix_size, &lzsize, - text + prefix_size, newlength); + png_ptr->read_buffer + prefix_size, &lzsize, + text + prefix_size, newlength); if (ret == Z_STREAM_END) { @@ -712,7 +717,7 @@ png_decompress_chunk(png_structrp png_ptr, * the extra space may otherwise be used as a Trojan Horse. */ if (ret == Z_STREAM_END && - chunklength - prefix_size != lzsize) + chunklength - prefix_size != lzsize) png_chunk_benign_error(png_ptr, "extra compressed data"); } @@ -754,6 +759,7 @@ png_decompress_chunk(png_structrp png_ptr, return Z_MEM_ERROR; } } +#endif /* READ_zTXt || READ_iTXt */ #endif /* READ_COMPRESSED_TEXT */ #ifdef PNG_READ_iCCP_SUPPORTED @@ -762,8 +768,8 @@ png_decompress_chunk(png_structrp png_ptr, */ static int png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size, - png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size, - int finish) + png_uint_32p chunk_bytes, png_bytep next_out, png_alloc_size_t *out_size, + int finish) { if (png_ptr->zowner == png_ptr->chunk_name) { @@ -802,8 +808,8 @@ png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size, * the available output is produced; this allows reading of truncated * streams. */ - ret = PNG_INFLATE(png_ptr, - *chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH)); + ret = PNG_INFLATE(png_ptr, *chunk_bytes > 0 ? + Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH)); } while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0)); @@ -821,7 +827,7 @@ png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size, return Z_STREAM_ERROR; } } -#endif +#endif /* READ_iCCP */ /* Read and check the IDHR chunk */ @@ -1009,7 +1015,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) #endif { - png_crc_finish(png_ptr, (int) length - num * 3); + png_crc_finish(png_ptr, (png_uint_32) (length - (unsigned int)num * 3)); } #ifndef PNG_READ_OPT_PLTE_SUPPORTED @@ -1292,7 +1298,7 @@ png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM; (void)png_colorspace_set_chromaticities(png_ptr, &png_ptr->colorspace, &xy, - 1/*prefer cHRM values*/); + 1/*prefer cHRM values*/); png_colorspace_sync(png_ptr, info_ptr); } #endif @@ -1432,8 +1438,8 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_ptr->zstream.next_in = (Bytef*)keyword + (keyword_length+2); png_ptr->zstream.avail_in = read_length; (void)png_inflate_read(png_ptr, local_buffer, - (sizeof local_buffer), &length, profile_header, &size, - 0/*finish: don't, because the output is too small*/); + (sizeof local_buffer), &length, profile_header, &size, + 0/*finish: don't, because the output is too small*/); if (size == 0) { @@ -1443,14 +1449,14 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) png_get_uint_32(profile_header); if (png_icc_check_length(png_ptr, &png_ptr->colorspace, - keyword, profile_length) != 0) + keyword, profile_length) != 0) { /* The length is apparently ok, so we can check the 132 * byte header. */ if (png_icc_check_header(png_ptr, &png_ptr->colorspace, - keyword, profile_length, profile_header, - png_ptr->color_type) != 0) + keyword, profile_length, profile_header, + png_ptr->color_type) != 0) { /* Now read the tag table; a variable size buffer is * needed at this point, allocate one for the whole @@ -1458,20 +1464,20 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) * that none of these stuff will overflow. */ const png_uint_32 tag_count = png_get_uint_32( - profile_header+128); + profile_header+128); png_bytep profile = png_read_buffer(png_ptr, - profile_length, 2/*silent*/); + profile_length, 2/*silent*/); if (profile != NULL) { memcpy(profile, profile_header, - (sizeof profile_header)); + (sizeof profile_header)); size = 12 * tag_count; (void)png_inflate_read(png_ptr, local_buffer, - (sizeof local_buffer), &length, - profile + (sizeof profile_header), &size, 0); + (sizeof local_buffer), &length, + profile + (sizeof profile_header), &size, 0); /* Still expect a buffer error because we expect * there to be some tag data! @@ -1479,22 +1485,22 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (size == 0) { if (png_icc_check_tag_table(png_ptr, - &png_ptr->colorspace, keyword, profile_length, - profile) != 0) + &png_ptr->colorspace, keyword, profile_length, + profile) != 0) { /* The profile has been validated for basic * security issues, so read the whole thing in. */ size = profile_length - (sizeof profile_header) - - 12 * tag_count; + - 12 * tag_count; (void)png_inflate_read(png_ptr, local_buffer, - (sizeof local_buffer), &length, - profile + (sizeof profile_header) + - 12 * tag_count, &size, 1/*finish*/); + (sizeof local_buffer), &length, + profile + (sizeof profile_header) + + 12 * tag_count, &size, 1/*finish*/); if (length > 0 && !(png_ptr->flags & - PNG_FLAG_BENIGN_ERRORS_WARN)) + PNG_FLAG_BENIGN_ERRORS_WARN)) errmsg = "extra compressed data"; /* But otherwise allow extra data: */ @@ -1506,34 +1512,34 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) * keep going. */ png_chunk_warning(png_ptr, - "extra compressed data"); + "extra compressed data"); } png_crc_finish(png_ptr, length); finished = 1; -# ifdef PNG_sRGB_SUPPORTED +# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0 /* Check for a match against sRGB */ png_icc_set_sRGB(png_ptr, - &png_ptr->colorspace, profile, - png_ptr->zstream.adler); -# endif + &png_ptr->colorspace, profile, + png_ptr->zstream.adler); +# endif /* Steal the profile for info_ptr. */ if (info_ptr != NULL) { png_free_data(png_ptr, info_ptr, - PNG_FREE_ICCP, 0); + PNG_FREE_ICCP, 0); info_ptr->iccp_name = png_voidcast(char*, - png_malloc_base(png_ptr, - keyword_length+1)); + png_malloc_base(png_ptr, + keyword_length+1)); if (info_ptr->iccp_name != NULL) { memcpy(info_ptr->iccp_name, keyword, - keyword_length+1); + keyword_length+1); info_ptr->iccp_proflen = - profile_length; + profile_length; info_ptr->iccp_profile = profile; png_ptr->read_buffer = NULL; /*steal*/ info_ptr->free_me |= PNG_FREE_ICCP; @@ -1715,13 +1721,13 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) data_length = length - (png_uint_32)(entry_start - buffer); /* Integrity-check the data length */ - if ((data_length % entry_size) != 0) + if ((data_length % (unsigned int)entry_size) != 0) { png_warning(png_ptr, "sPLT chunk has bad length"); return; } - dl = (png_int_32)(data_length / entry_size); + dl = (png_uint_32)(data_length / (unsigned int)entry_size); max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry)); if (dl > max_dl) @@ -1730,10 +1736,10 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) return; } - new_palette.nentries = (png_int_32)(data_length / entry_size); + new_palette.nentries = (png_int_32)(data_length / (unsigned int)entry_size); - new_palette.entries = (png_sPLT_entryp)png_malloc_warn( - png_ptr, new_palette.nentries * (sizeof (png_sPLT_entry))); + new_palette.entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, + (png_alloc_size_t) new_palette.nentries * (sizeof (png_sPLT_entry))); if (new_palette.entries == NULL) { @@ -2270,7 +2276,7 @@ png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) } png_set_pCAL(png_ptr, info_ptr, (png_charp)buffer, X0, X1, type, nparams, - (png_charp)units, params); + (png_charp)units, params); png_free(png_ptr, params); } @@ -2313,7 +2319,7 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) } png_debug1(2, "Allocating and reading sCAL chunk data (%u bytes)", - length + 1); + length + 1); buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/); @@ -2365,7 +2371,7 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) else /* This is the (only) success case. */ png_set_sCAL_s(png_ptr, info_ptr, buffer[0], - (png_charp)buffer+1, (png_charp)buffer+heighti); + (png_charp)buffer+1, (png_charp)buffer+heighti); } } #endif @@ -2465,8 +2471,8 @@ png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (buffer == NULL) { - png_chunk_benign_error(png_ptr, "out of memory"); - return; + png_chunk_benign_error(png_ptr, "out of memory"); + return; } png_crc_read(png_ptr, buffer, length); @@ -2573,7 +2579,7 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) * and text chunks. */ if (png_decompress_chunk(png_ptr, length, keyword_length+2, - &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) + &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) { png_text text; @@ -2713,7 +2719,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) * iCCP and text chunks. */ if (png_decompress_chunk(png_ptr, length, prefix_length, - &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) + &uncompressed_length, 1/*terminate*/) == Z_STREAM_END) buffer = png_ptr->read_buffer; else @@ -2793,7 +2799,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length) { /* Do a 'warn' here - it is handled below. */ png_ptr->unknown_chunk.data = png_voidcast(png_bytep, - png_malloc_warn(png_ptr, length)); + png_malloc_warn(png_ptr, length)); } } @@ -2818,7 +2824,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length) /* Handle an unknown, or known but disabled, chunk */ void /* PRIVATE */ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, - png_uint_32 length, int keep) + png_uint_32 length, int keep) { int handled = 0; /* the chunk was handled */ @@ -2856,7 +2862,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, { /* Callback to user unknown chunk handler */ int ret = (*(png_ptr->read_user_chunk_fn))(png_ptr, - &png_ptr->unknown_chunk); + &png_ptr->unknown_chunk); /* ret is: * negative: An error occurred; png_chunk_error will be called. @@ -2890,9 +2896,9 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, { png_chunk_warning(png_ptr, "Saving unknown chunk:"); png_app_warning(png_ptr, - "forcing save of an unhandled chunk;" - " please call png_set_keep_unknown_chunks"); - /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */ + "forcing save of an unhandled chunk;" + " please call png_set_keep_unknown_chunks"); + /* with keep = PNG_HANDLE_CHUNK_IF_SAFE */ } # endif keep = PNG_HANDLE_CHUNK_IF_SAFE; @@ -2985,7 +2991,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, * out; store the chunk. */ png_set_unknown_chunks(png_ptr, info_ptr, - &png_ptr->unknown_chunk, 1); + &png_ptr->unknown_chunk, 1); handled = 1; # ifdef PNG_USER_LIMITS_SUPPORTED break; @@ -3097,7 +3103,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) # ifdef PNG_READ_PACKSWAP_SUPPORTED if ((png_ptr->transformations & PNG_PACKSWAP) != 0) /* little-endian byte */ - end_mask = 0xff << end_mask; + end_mask = (unsigned int)(0xff << end_mask); else /* big-endian byte */ # endif @@ -3418,8 +3424,8 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) /* Everything is aligned for png_uint_16 copies, but try for * png_uint_32 first. */ - if (png_isaligned(dp, png_uint_32) != 0 && - png_isaligned(sp, png_uint_32) != 0 && + if (png_isaligned(dp, png_uint_32) && + png_isaligned(sp, png_uint_32) && bytes_to_copy % (sizeof (png_uint_32)) == 0 && bytes_to_jump % (sizeof (png_uint_32)) == 0) { @@ -3539,11 +3545,11 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) #ifdef PNG_READ_INTERLACING_SUPPORTED void /* PRIVATE */ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, - png_uint_32 transformations /* Because these may affect the byte layout */) + png_uint_32 transformations /* Because these may affect the byte layout */) { /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Offset to next interlace block */ - static PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; + static PNG_CONST unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; png_debug(1, "in png_do_read_interlace"); if (row != NULL && row_info != NULL) @@ -3558,9 +3564,10 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, { png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3); png_bytep dp = row + (png_size_t)((final_width - 1) >> 3); - int sshift, dshift; - int s_start, s_end, s_inc; - int jstop = png_pass_inc[pass]; + unsigned int sshift, dshift; + unsigned int s_start, s_end; + int s_inc; + int jstop = (int)png_pass_inc[pass]; png_byte v; png_uint_32 i; int j; @@ -3568,8 +3575,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, #ifdef PNG_READ_PACKSWAP_SUPPORTED if ((transformations & PNG_PACKSWAP) != 0) { - sshift = (int)((row_info->width + 7) & 0x07); - dshift = (int)((final_width + 7) & 0x07); + sshift = ((row_info->width + 7) & 0x07); + dshift = ((final_width + 7) & 0x07); s_start = 7; s_end = 0; s_inc = -1; @@ -3578,8 +3585,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, else #endif { - sshift = 7 - (int)((row_info->width + 7) & 0x07); - dshift = 7 - (int)((final_width + 7) & 0x07); + sshift = 7 - ((row_info->width + 7) & 0x07); + dshift = 7 - ((final_width + 7) & 0x07); s_start = 0; s_end = 7; s_inc = 1; @@ -3591,7 +3598,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, for (j = 0; j < jstop; j++) { unsigned int tmp = *dp & (0x7f7f >> (7 - dshift)); - tmp |= v << dshift; + tmp |= (unsigned int)(v << dshift); *dp = (png_byte)(tmp & 0xff); if (dshift == s_end) @@ -3601,7 +3608,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, } else - dshift += s_inc; + dshift = (unsigned int)((int)dshift + s_inc); } if (sshift == s_end) @@ -3611,7 +3618,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, } else - sshift += s_inc; + sshift = (unsigned int)((int)sshift + s_inc); } break; } @@ -3620,16 +3627,17 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, { png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2); - int sshift, dshift; - int s_start, s_end, s_inc; - int jstop = png_pass_inc[pass]; + unsigned int sshift, dshift; + unsigned int s_start, s_end; + int s_inc; + int jstop = (int)png_pass_inc[pass]; png_uint_32 i; #ifdef PNG_READ_PACKSWAP_SUPPORTED if ((transformations & PNG_PACKSWAP) != 0) { - sshift = (int)(((row_info->width + 3) & 0x03) << 1); - dshift = (int)(((final_width + 3) & 0x03) << 1); + sshift = (((row_info->width + 3) & 0x03) << 1); + dshift = (((final_width + 3) & 0x03) << 1); s_start = 6; s_end = 0; s_inc = -2; @@ -3638,8 +3646,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, else #endif { - sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1); - dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1); + sshift = ((3 - ((row_info->width + 3) & 0x03)) << 1); + dshift = ((3 - ((final_width + 3) & 0x03)) << 1); s_start = 0; s_end = 6; s_inc = 2; @@ -3654,7 +3662,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, for (j = 0; j < jstop; j++) { unsigned int tmp = *dp & (0x3f3f >> (6 - dshift)); - tmp |= v << dshift; + tmp |= (unsigned int)(v << dshift); *dp = (png_byte)(tmp & 0xff); if (dshift == s_end) @@ -3664,7 +3672,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, } else - dshift += s_inc; + dshift = (unsigned int)((int)dshift + s_inc); } if (sshift == s_end) @@ -3674,7 +3682,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, } else - sshift += s_inc; + sshift = (unsigned int)((int)sshift + s_inc); } break; } @@ -3683,16 +3691,17 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, { png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1); png_bytep dp = row + (png_size_t)((final_width - 1) >> 1); - int sshift, dshift; - int s_start, s_end, s_inc; + unsigned int sshift, dshift; + unsigned int s_start, s_end; + int s_inc; png_uint_32 i; - int jstop = png_pass_inc[pass]; + int jstop = (int)png_pass_inc[pass]; #ifdef PNG_READ_PACKSWAP_SUPPORTED if ((transformations & PNG_PACKSWAP) != 0) { - sshift = (int)(((row_info->width + 1) & 0x01) << 2); - dshift = (int)(((final_width + 1) & 0x01) << 2); + sshift = (((row_info->width + 1) & 0x01) << 2); + dshift = (((final_width + 1) & 0x01) << 2); s_start = 4; s_end = 0; s_inc = -4; @@ -3701,8 +3710,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, else #endif { - sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2); - dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2); + sshift = ((1 - ((row_info->width + 1) & 0x01)) << 2); + dshift = ((1 - ((final_width + 1) & 0x01)) << 2); s_start = 0; s_end = 4; s_inc = 4; @@ -3716,7 +3725,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, for (j = 0; j < jstop; j++) { unsigned int tmp = *dp & (0xf0f >> (4 - dshift)); - tmp |= v << dshift; + tmp |= (unsigned int)(v << dshift); *dp = (png_byte)(tmp & 0xff); if (dshift == s_end) @@ -3726,7 +3735,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, } else - dshift += s_inc; + dshift = (unsigned int)((int)dshift + s_inc); } if (sshift == s_end) @@ -3736,7 +3745,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, } else - sshift += s_inc; + sshift = (unsigned int)((int)sshift + s_inc); } break; } @@ -3750,7 +3759,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes; - int jstop = png_pass_inc[pass]; + int jstop = (int)png_pass_inc[pass]; png_uint_32 i; for (i = 0; i < row_info->width; i++) @@ -3783,7 +3792,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass, static void png_read_filter_row_sub(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) + png_const_bytep prev_row) { png_size_t i; png_size_t istop = row_info->rowbytes; @@ -3801,7 +3810,7 @@ png_read_filter_row_sub(png_row_infop row_info, png_bytep row, static void png_read_filter_row_up(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) + png_const_bytep prev_row) { png_size_t i; png_size_t istop = row_info->rowbytes; @@ -3817,7 +3826,7 @@ png_read_filter_row_up(png_row_infop row_info, png_bytep row, static void png_read_filter_row_avg(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) + png_const_bytep prev_row) { png_size_t i; png_bytep rp = row; @@ -3844,7 +3853,7 @@ png_read_filter_row_avg(png_row_infop row_info, png_bytep row, static void png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) + png_const_bytep prev_row) { png_bytep rp_end = row + row_info->rowbytes; int a, c; @@ -3892,9 +3901,9 @@ png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row, static void png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row, - png_const_bytep prev_row) + png_const_bytep prev_row) { - int bpp = (row_info->pixel_depth + 7) >> 3; + unsigned int bpp = (row_info->pixel_depth + 7) >> 3; png_bytep rp_end = row + bpp; /* Process the first pixel in the row completely (this is the same as 'up' @@ -3907,7 +3916,7 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row, } /* Remainder */ - rp_end += row_info->rowbytes - bpp; + rp_end = rp_end + (row_info->rowbytes - bpp); while (row < rp_end) { @@ -3977,7 +3986,7 @@ png_init_filter_functions(png_structrp pp) void /* PRIVATE */ png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row, - png_const_bytep prev_row, int filter) + png_const_bytep prev_row, int filter) { /* OPTIMIZATION: DO NOT MODIFY THIS FUNCTION, instead #define * PNG_FILTER_OPTIMIZATIONS to a function that overrides the generic @@ -3995,7 +4004,7 @@ png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row, #ifdef PNG_SEQUENTIAL_READ_SUPPORTED void /* PRIVATE */ png_read_IDAT_data(png_structrp png_ptr, png_bytep output, - png_alloc_size_t avail_out) + png_alloc_size_t avail_out) { /* Loop reading IDATs and decompressing the result into output[avail_out] */ png_ptr->zstream.next_out = output; @@ -4252,7 +4261,7 @@ png_read_start_row(png_structrp png_ptr) /* Offset to next interlace block in the y direction */ static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; - int max_pixel_depth; + unsigned int max_pixel_depth; png_size_t row_bytes; png_debug(1, "in png_read_start_row"); @@ -4281,7 +4290,7 @@ png_read_start_row(png_structrp png_ptr) png_ptr->iwidth = png_ptr->width; } - max_pixel_depth = png_ptr->pixel_depth; + max_pixel_depth = (unsigned int)png_ptr->pixel_depth; /* WARNING: * png_read_transform_info (pngrtran.c) performs a simpler set of * calculations to calculate the final pixel depth, then @@ -4416,7 +4425,7 @@ png_read_start_row(png_structrp png_ptr) defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0) { - int user_pixel_depth = png_ptr->user_transform_depth * + unsigned int user_pixel_depth = png_ptr->user_transform_depth * png_ptr->user_transform_channels; if (user_pixel_depth > max_pixel_depth) @@ -4438,7 +4447,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) * for safety's sake */ row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) + - 1 + ((max_pixel_depth + 7) >> 3); + 1 + ((max_pixel_depth + 7) >> 3U); #ifdef PNG_MAX_MALLOC_64K if (row_bytes > (png_uint_32)65536L) @@ -4447,42 +4456,42 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) if (row_bytes + 48 > png_ptr->old_big_row_buf_size) { - png_free(png_ptr, png_ptr->big_row_buf); - png_free(png_ptr, png_ptr->big_prev_row); + png_free(png_ptr, png_ptr->big_row_buf); + png_free(png_ptr, png_ptr->big_prev_row); - if (png_ptr->interlaced != 0) - png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr, - row_bytes + 48); + if (png_ptr->interlaced != 0) + png_ptr->big_row_buf = (png_bytep)png_calloc(png_ptr, + row_bytes + 48); - else - png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 48); + else + png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 48); - png_ptr->big_prev_row = (png_bytep)png_malloc(png_ptr, row_bytes + 48); + png_ptr->big_prev_row = (png_bytep)png_malloc(png_ptr, row_bytes + 48); #ifdef PNG_ALIGNED_MEMORY_SUPPORTED - /* Use 16-byte aligned memory for row_buf with at least 16 bytes - * of padding before and after row_buf; treat prev_row similarly. - * NOTE: the alignment is to the start of the pixels, one beyond the start - * of the buffer, because of the filter byte. Prior to libpng 1.5.6 this - * was incorrect; the filter byte was aligned, which had the exact - * opposite effect of that intended. - */ - { - png_bytep temp = png_ptr->big_row_buf + 32; - int extra = (int)((temp - (png_bytep)0) & 0x0f); - png_ptr->row_buf = temp - extra - 1/*filter byte*/; - - temp = png_ptr->big_prev_row + 32; - extra = (int)((temp - (png_bytep)0) & 0x0f); - png_ptr->prev_row = temp - extra - 1/*filter byte*/; - } + /* Use 16-byte aligned memory for row_buf with at least 16 bytes + * of padding before and after row_buf; treat prev_row similarly. + * NOTE: the alignment is to the start of the pixels, one beyond the start + * of the buffer, because of the filter byte. Prior to libpng 1.5.6 this + * was incorrect; the filter byte was aligned, which had the exact + * opposite effect of that intended. + */ + { + png_bytep temp = png_ptr->big_row_buf + 32; + int extra = (int)((temp - (png_bytep)0) & 0x0f); + png_ptr->row_buf = temp - extra - 1/*filter byte*/; + + temp = png_ptr->big_prev_row + 32; + extra = (int)((temp - (png_bytep)0) & 0x0f); + png_ptr->prev_row = temp - extra - 1/*filter byte*/; + } #else - /* Use 31 bytes of padding before and 17 bytes after row_buf. */ - png_ptr->row_buf = png_ptr->big_row_buf + 31; - png_ptr->prev_row = png_ptr->big_prev_row + 31; + /* Use 31 bytes of padding before and 17 bytes after row_buf. */ + png_ptr->row_buf = png_ptr->big_row_buf + 31; + png_ptr->prev_row = png_ptr->big_prev_row + 31; #endif - png_ptr->old_big_row_buf_size = row_bytes + 48; + png_ptr->old_big_row_buf_size = row_bytes + 48; } #ifdef PNG_MAX_MALLOC_64K @@ -4507,7 +4516,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) * does not, so free the read buffer now regardless; the sequential reader * reallocates it on demand. */ - if (png_ptr->read_buffer != 0) + if (png_ptr->read_buffer != NULL) { png_bytep buffer = png_ptr->read_buffer; diff --git a/src/3rdparty/libpng/pngset.c b/src/3rdparty/libpng/pngset.c index 8fd7965fca..28ff3a064d 100644 --- a/src/3rdparty/libpng/pngset.c +++ b/src/3rdparty/libpng/pngset.c @@ -1,8 +1,8 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.6.19 [November 12, 2015] - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -104,14 +104,14 @@ png_set_cHRM(png_const_structrp png_ptr, png_inforp info_ptr, double green_x, double green_y, double blue_x, double blue_y) { png_set_cHRM_fixed(png_ptr, info_ptr, - png_fixed(png_ptr, white_x, "cHRM White X"), - png_fixed(png_ptr, white_y, "cHRM White Y"), - png_fixed(png_ptr, red_x, "cHRM Red X"), - png_fixed(png_ptr, red_y, "cHRM Red Y"), - png_fixed(png_ptr, green_x, "cHRM Green X"), - png_fixed(png_ptr, green_y, "cHRM Green Y"), - png_fixed(png_ptr, blue_x, "cHRM Blue X"), - png_fixed(png_ptr, blue_y, "cHRM Blue Y")); + png_fixed(png_ptr, white_x, "cHRM White X"), + png_fixed(png_ptr, white_y, "cHRM White Y"), + png_fixed(png_ptr, red_x, "cHRM Red X"), + png_fixed(png_ptr, red_y, "cHRM Red Y"), + png_fixed(png_ptr, green_x, "cHRM Green X"), + png_fixed(png_ptr, green_y, "cHRM Green Y"), + png_fixed(png_ptr, blue_x, "cHRM Blue X"), + png_fixed(png_ptr, blue_y, "cHRM Blue Y")); } void PNGAPI @@ -120,15 +120,15 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X, double blue_X, double blue_Y, double blue_Z) { png_set_cHRM_XYZ_fixed(png_ptr, info_ptr, - png_fixed(png_ptr, red_X, "cHRM Red X"), - png_fixed(png_ptr, red_Y, "cHRM Red Y"), - png_fixed(png_ptr, red_Z, "cHRM Red Z"), - png_fixed(png_ptr, green_X, "cHRM Green X"), - png_fixed(png_ptr, green_Y, "cHRM Green Y"), - png_fixed(png_ptr, green_Z, "cHRM Green Z"), - png_fixed(png_ptr, blue_X, "cHRM Blue X"), - png_fixed(png_ptr, blue_Y, "cHRM Blue Y"), - png_fixed(png_ptr, blue_Z, "cHRM Blue Z")); + png_fixed(png_ptr, red_X, "cHRM Red X"), + png_fixed(png_ptr, red_Y, "cHRM Red Y"), + png_fixed(png_ptr, red_Z, "cHRM Red Z"), + png_fixed(png_ptr, green_X, "cHRM Green X"), + png_fixed(png_ptr, green_Y, "cHRM Green Y"), + png_fixed(png_ptr, green_Z, "cHRM Green Z"), + png_fixed(png_ptr, blue_X, "cHRM Blue X"), + png_fixed(png_ptr, blue_Y, "cHRM Blue Y"), + png_fixed(png_ptr, blue_Z, "cHRM Blue Z")); } # endif /* FLOATING_POINT */ @@ -283,17 +283,29 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, /* Check that the type matches the specification. */ if (type < 0 || type > 3) - png_error(png_ptr, "Invalid pCAL equation type"); + { + png_chunk_report(png_ptr, "Invalid pCAL equation type", + PNG_CHUNK_WRITE_ERROR); + return; + } if (nparams < 0 || nparams > 255) - png_error(png_ptr, "Invalid pCAL parameter count"); + { + png_chunk_report(png_ptr, "Invalid pCAL parameter count", + PNG_CHUNK_WRITE_ERROR); + return; + } /* Validate params[nparams] */ for (i=0; ipcal_purpose = png_voidcast(png_charp, @@ -301,8 +313,8 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, if (info_ptr->pcal_purpose == NULL) { - png_warning(png_ptr, "Insufficient memory for pCAL purpose"); - + png_chunk_report(png_ptr, "Insufficient memory for pCAL purpose", + PNG_CHUNK_WRITE_ERROR); return; } @@ -316,10 +328,10 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, length = strlen(units) + 1; png_debug1(3, "allocating units for info (%lu bytes)", - (unsigned long)length); + (unsigned long)length); info_ptr->pcal_units = png_voidcast(png_charp, - png_malloc_warn(png_ptr, length)); + png_malloc_warn(png_ptr, length)); if (info_ptr->pcal_units == NULL) { @@ -331,7 +343,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, memcpy(info_ptr->pcal_units, units, length); info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr, - (png_size_t)((nparams + 1) * (sizeof (png_charp))))); + (png_size_t)(((unsigned int)nparams + 1) * (sizeof (png_charp))))); if (info_ptr->pcal_params == NULL) { @@ -340,7 +352,8 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, return; } - memset(info_ptr->pcal_params, 0, (nparams + 1) * (sizeof (png_charp))); + memset(info_ptr->pcal_params, 0, ((unsigned int)nparams + 1) * + (sizeof (png_charp))); for (i = 0; i < nparams; i++) { @@ -398,7 +411,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr, png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthw); info_ptr->scal_s_width = png_voidcast(png_charp, - png_malloc_warn(png_ptr, lengthw)); + png_malloc_warn(png_ptr, lengthw)); if (info_ptr->scal_s_width == NULL) { @@ -414,7 +427,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr, png_debug1(3, "allocating unit for info (%u bytes)", (unsigned int)lengthh); info_ptr->scal_s_height = png_voidcast(png_charp, - png_malloc_warn(png_ptr, lengthh)); + png_malloc_warn(png_ptr, lengthh)); if (info_ptr->scal_s_height == NULL) { @@ -453,9 +466,9 @@ png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit, char sheight[PNG_sCAL_MAX_DIGITS+1]; png_ascii_from_fp(png_ptr, swidth, (sizeof swidth), width, - PNG_sCAL_PRECISION); + PNG_sCAL_PRECISION); png_ascii_from_fp(png_ptr, sheight, (sizeof sheight), height, - PNG_sCAL_PRECISION); + PNG_sCAL_PRECISION); png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight); } @@ -563,7 +576,8 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, PNG_MAX_PALETTE_LENGTH * (sizeof (png_color)))); if (num_palette > 0) - memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color))); + memcpy(png_ptr->palette, palette, (unsigned int)num_palette * + (sizeof (png_color))); info_ptr->palette = png_ptr->palette; info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; @@ -648,7 +662,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, */ { int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name, - proflen, profile, info_ptr->color_type); + proflen, profile, info_ptr->color_type); png_colorspace_sync_info(png_ptr, info_ptr); @@ -673,7 +687,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, memcpy(new_iccp_name, name, length); new_iccp_profile = png_voidcast(png_bytep, - png_malloc_warn(png_ptr, proflen)); + png_malloc_warn(png_ptr, proflen)); if (new_iccp_profile == NULL) { @@ -748,14 +762,14 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, * the overflow checks. */ new_text = png_voidcast(png_textp,png_realloc_array(png_ptr, - info_ptr->text, old_num_text, max_text-old_num_text, - sizeof *new_text)); + info_ptr->text, old_num_text, max_text-old_num_text, + sizeof *new_text)); } if (new_text == NULL) { png_chunk_report(png_ptr, "too many text chunks", - PNG_CHUNK_WRITE_ERROR); + PNG_CHUNK_WRITE_ERROR); return 1; } @@ -783,7 +797,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST) { png_chunk_report(png_ptr, "text compression mode is out of range", - PNG_CHUNK_WRITE_ERROR); + PNG_CHUNK_WRITE_ERROR); continue; } @@ -815,7 +829,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, # else /* iTXt */ { png_chunk_report(png_ptr, "iTXt chunk not supported", - PNG_CHUNK_WRITE_ERROR); + PNG_CHUNK_WRITE_ERROR); continue; } # endif @@ -844,7 +858,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, if (textp->key == NULL) { png_chunk_report(png_ptr, "text chunk: out of memory", - PNG_CHUNK_WRITE_ERROR); + PNG_CHUNK_WRITE_ERROR); return 1; } @@ -952,12 +966,14 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); - /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ - png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep, - png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH)); - if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) + { + /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ + info_ptr->trans_alpha = png_voidcast(png_bytep, + png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH)); memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans); + } + png_ptr->trans_alpha = info_ptr->trans_alpha; } if (trans_color != NULL) @@ -974,7 +990,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, trans_color->green > sample_max || trans_color->blue > sample_max))) png_warning(png_ptr, - "tRNS chunk has out-of-range samples for bit_depth"); + "tRNS chunk has out-of-range samples for bit_depth"); } #endif @@ -1016,8 +1032,8 @@ png_set_sPLT(png_const_structrp png_ptr, * overflows. Notice that the parameters are (int) and (size_t) */ np = png_voidcast(png_sPLT_tp,png_realloc_array(png_ptr, - info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries, - sizeof *np)); + info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries, + sizeof *np)); if (np == NULL) { @@ -1078,7 +1094,7 @@ png_set_sPLT(png_const_structrp png_ptr, * checked it when doing the allocation. */ memcpy(np->entries, entries->entries, - entries->nentries * sizeof (png_sPLT_entry)); + (unsigned int)entries->nentries * sizeof (png_sPLT_entry)); /* Note that 'continue' skips the advance of the out pointer and out * count, so an invalid entry is not added. @@ -1108,10 +1124,10 @@ check_location(png_const_structrp png_ptr, int location) { /* Write struct, so unknown chunks come from the app */ png_app_warning(png_ptr, - "png_set_unknown_chunks now expects a valid location"); + "png_set_unknown_chunks now expects a valid location"); /* Use the old behavior */ location = (png_byte)(png_ptr->mode & - (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)); + (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)); } /* This need not be an internal error - if the app calls @@ -1134,7 +1150,7 @@ check_location(png_const_structrp png_ptr, int location) void PNGAPI png_set_unknown_chunks(png_const_structrp png_ptr, - png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns) + png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns) { png_unknown_chunkp np; @@ -1173,13 +1189,13 @@ png_set_unknown_chunks(png_const_structrp png_ptr, * appropriate to read or write. */ np = png_voidcast(png_unknown_chunkp, png_realloc_array(png_ptr, - info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns, - sizeof *np)); + info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns, + sizeof *np)); if (np == NULL) { png_chunk_report(png_ptr, "too many unknown chunks", - PNG_CHUNK_WRITE_ERROR); + PNG_CHUNK_WRITE_ERROR); return; } @@ -1208,12 +1224,12 @@ png_set_unknown_chunks(png_const_structrp png_ptr, else { np->data = png_voidcast(png_bytep, - png_malloc_base(png_ptr, unknowns->size)); + png_malloc_base(png_ptr, unknowns->size)); if (np->data == NULL) { png_chunk_report(png_ptr, "unknown chunk: out of memory", - PNG_CHUNK_WRITE_ERROR); + PNG_CHUNK_WRITE_ERROR); /* But just skip storing the unknown chunk */ continue; } @@ -1247,7 +1263,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr, { png_app_error(png_ptr, "invalid unknown chunk location"); /* Fake out the pre 1.6.0 behavior: */ - if ((location & PNG_HAVE_IDAT) != 0) /* undocumented! */ + if (((unsigned int)location & PNG_HAVE_IDAT) != 0) /* undocumented! */ location = PNG_AFTER_IDAT; else @@ -1371,7 +1387,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, return; } - num_chunks = num_chunks_in; + num_chunks = (unsigned int)num_chunks_in; } old_num_chunks = png_ptr->num_chunk_list; @@ -1420,7 +1436,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, for (i=0; i PNG_UINT_31_MAX) - png_error(png_ptr, "invalid compression buffer size"); + if (size == 0 || size > PNG_UINT_31_MAX) + png_error(png_ptr, "invalid compression buffer size"); # ifdef PNG_SEQUENTIAL_READ_SUPPORTED - if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) - { - png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */ - return; - } + if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0) + { + png_ptr->IDAT_read_size = (png_uint_32)size; /* checked above */ + return; + } # endif # ifdef PNG_WRITE_SUPPORTED - if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0) + if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0) + { + if (png_ptr->zowner != 0) { - if (png_ptr->zowner != 0) - { - png_warning(png_ptr, - "Compression buffer size cannot be changed because it is in use"); + png_warning(png_ptr, + "Compression buffer size cannot be changed because it is in use"); - return; - } + return; + } #ifndef __COVERITY__ - /* Some compilers complain that this is always false. However, it - * can be true when integer overflow happens. - */ - if (size > ZLIB_IO_MAX) - { - png_warning(png_ptr, - "Compression buffer size limited to system maximum"); - size = ZLIB_IO_MAX; /* must fit */ - } + /* Some compilers complain that this is always false. However, it + * can be true when integer overflow happens. + */ + if (size > ZLIB_IO_MAX) + { + png_warning(png_ptr, + "Compression buffer size limited to system maximum"); + size = ZLIB_IO_MAX; /* must fit */ + } #endif - if (size < 6) - { - /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH - * if this is permitted. - */ - png_warning(png_ptr, - "Compression buffer size cannot be reduced below 6"); + if (size < 6) + { + /* Deflate will potentially go into an infinite loop on a SYNC_FLUSH + * if this is permitted. + */ + png_warning(png_ptr, + "Compression buffer size cannot be reduced below 6"); - return; - } + return; + } - if (png_ptr->zbuffer_size != size) - { - png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list); - png_ptr->zbuffer_size = (uInt)size; - } + if (png_ptr->zbuffer_size != size) + { + png_free_buffer_list(png_ptr, &png_ptr->zbuffer_list); + png_ptr->zbuffer_size = (uInt)size; } + } # endif } @@ -1561,7 +1577,7 @@ void PNGAPI png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask) { if (png_ptr != NULL && info_ptr != NULL) - info_ptr->valid &= ~mask; + info_ptr->valid &= (unsigned int)(~mask); } @@ -1644,4 +1660,92 @@ png_set_check_for_invalid_index(png_structrp png_ptr, int allowed) png_ptr->num_palette_max = -1; } #endif + +#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) || \ + defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) +/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, + * and if invalid, correct the keyword rather than discarding the entire + * chunk. The PNG 1.0 specification requires keywords 1-79 characters in + * length, forbids leading or trailing whitespace, multiple internal spaces, + * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. + * + * The 'new_key' buffer must be 80 characters in size (for the keyword plus a + * trailing '\0'). If this routine returns 0 then there was no keyword, or a + * valid one could not be generated, and the caller must png_error. + */ +png_uint_32 /* PRIVATE */ +png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key) +{ +#ifdef PNG_WARNINGS_SUPPORTED + png_const_charp orig_key = key; +#endif + png_uint_32 key_len = 0; + int bad_character = 0; + int space = 1; + + png_debug(1, "in png_check_keyword"); + + if (key == NULL) + { + *new_key = 0; + return 0; + } + + while (*key && key_len < 79) + { + png_byte ch = (png_byte)*key++; + + if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/)) + *new_key++ = ch, ++key_len, space = 0; + + else if (space == 0) + { + /* A space or an invalid character when one wasn't seen immediately + * before; output just a space. + */ + *new_key++ = 32, ++key_len, space = 1; + + /* If the character was not a space then it is invalid. */ + if (ch != 32) + bad_character = ch; + } + + else if (bad_character == 0) + bad_character = ch; /* just skip it, record the first error */ + } + + if (key_len > 0 && space != 0) /* trailing space */ + { + --key_len, --new_key; + if (bad_character == 0) + bad_character = 32; + } + + /* Terminate the keyword */ + *new_key = 0; + + if (key_len == 0) + return 0; + +#ifdef PNG_WARNINGS_SUPPORTED + /* Try to only output one warning per keyword: */ + if (*key != 0) /* keyword too long */ + png_warning(png_ptr, "keyword truncated"); + + else if (bad_character != 0) + { + PNG_WARNING_PARAMETERS(p) + + png_warning_parameter(p, 1, orig_key); + png_warning_parameter_signed(p, 2, PNG_NUMBER_FORMAT_02x, bad_character); + + png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'"); + } +#else /* !WARNINGS */ + PNG_UNUSED(png_ptr) +#endif /* !WARNINGS */ + + return key_len; +} +#endif /* TEXT || pCAL || iCCP || sPLT */ #endif /* READ || WRITE */ diff --git a/src/3rdparty/libpng/pngstruct.h b/src/3rdparty/libpng/pngstruct.h index d0bcc7914a..749d7e35b1 100644 --- a/src/3rdparty/libpng/pngstruct.h +++ b/src/3rdparty/libpng/pngstruct.h @@ -1,8 +1,8 @@ /* pngstruct.h - header file for PNG reference library * - * Last changed in libpng 1.6.18 [July 23, 2015] - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.28 [January 5, 2017] + * Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -249,7 +249,7 @@ struct png_struct_def png_byte filter; /* file filter type (always 0) */ png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ png_byte pass; /* current interlace pass (0 - 6) */ - png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ + png_byte do_filter; /* row filter flags (see PNG_FILTER_ in png.h ) */ png_byte color_type; /* color type of file */ png_byte bit_depth; /* bit depth of file */ png_byte usr_bit_depth; /* bit depth of users row: write only */ @@ -263,7 +263,7 @@ struct png_struct_def /* pixel depth used for the row buffers */ png_byte transformed_pixel_depth; /* pixel depth after read/write transforms */ -#if PNG_ZLIB_VERNUM >= 0x1240 +#if ZLIB_VERNUM >= 0x1240 png_byte zstream_start; /* at start of an input zlib stream */ #endif /* Zlib >= 1.2.4 */ #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) @@ -353,7 +353,7 @@ struct png_struct_def /* Options */ #ifdef PNG_SET_OPTION_SUPPORTED - png_byte options; /* On/off state (up to 4 options) */ + png_uint_32 options; /* On/off state (up to 16 options) */ #endif #if PNG_LIBPNG_VER < 10700 diff --git a/src/3rdparty/libpng/pngtrans.c b/src/3rdparty/libpng/pngtrans.c index 0c0d92d8fd..da7413fb80 100644 --- a/src/3rdparty/libpng/pngtrans.c +++ b/src/3rdparty/libpng/pngtrans.c @@ -1,8 +1,8 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * Last changed in libpng 1.6.18 [July 23, 2015] - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -172,13 +172,14 @@ png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc) * size! */ png_app_error(png_ptr, - "png_set_filler is invalid for low bit depth gray output"); + "png_set_filler is invalid for" + " low bit depth gray output"); return; } default: png_app_error(png_ptr, - "png_set_filler: inappropriate color type"); + "png_set_filler: inappropriate color type"); return; } # else @@ -594,7 +595,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) return; /* The filler channel has gone already */ /* Fix the rowbytes value. */ - row_info->rowbytes = dp-row; + row_info->rowbytes = (unsigned int)(dp-row); } #endif @@ -692,7 +693,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info) * and this calculation is used because it avoids warnings that other * forms produced on either GCC or MSVC. */ - int padding = (-row_info->pixel_depth * row_info->width) & 7; + int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width); png_bytep rp = png_ptr->row_buf + row_info->rowbytes; switch (row_info->bit_depth) @@ -797,7 +798,7 @@ png_set_user_transform_info(png_structrp png_ptr, png_voidp (png_ptr->flags & PNG_FLAG_ROW_INIT) != 0) { png_app_error(png_ptr, - "info change after png_start_read_image or png_read_update_info"); + "info change after png_start_read_image or png_read_update_info"); return; } #endif diff --git a/src/3rdparty/libpng/pngwio.c b/src/3rdparty/libpng/pngwio.c index db76e6b8d7..37c7c3a7f0 100644 --- a/src/3rdparty/libpng/pngwio.c +++ b/src/3rdparty/libpng/pngwio.c @@ -1,8 +1,8 @@ /* pngwio.c - functions for data output * - * Last changed in libpng 1.6.15 [November 20, 2014] - * Copyright (c) 1998-2014 Glenn Randers-Pehrson + * Last changed in libpng 1.6.24 [August 4, 2016] + * Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -35,7 +35,7 @@ png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length) /* NOTE: write_data_fn must not change the buffer! */ if (png_ptr->write_data_fn != NULL ) (*(png_ptr->write_data_fn))(png_ptr, png_constcast(png_bytep,data), - length); + length); else png_error(png_ptr, "Call to NULL write function"); diff --git a/src/3rdparty/libpng/pngwrite.c b/src/3rdparty/libpng/pngwrite.c index 0d4ee9f7ae..07088ee75e 100644 --- a/src/3rdparty/libpng/pngwrite.c +++ b/src/3rdparty/libpng/pngwrite.c @@ -1,8 +1,8 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.6.19 [November 12, 2015] - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -12,9 +12,9 @@ */ #include "pngpriv.h" -#if defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) +#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED # include -#endif +#endif /* SIMPLIFIED_WRITE_STDIO */ #ifdef PNG_WRITE_SUPPORTED @@ -22,7 +22,7 @@ /* Write out all the unknown chunks for the current given location */ static void write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr, - unsigned int where) + unsigned int where) { if (info_ptr->unknown_chunks_num != 0) { @@ -148,11 +148,11 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr) # ifdef PNG_WRITE_sRGB_SUPPORTED if ((info_ptr->valid & PNG_INFO_sRGB) != 0) png_app_warning(png_ptr, - "profile matches sRGB but writing iCCP instead"); + "profile matches sRGB but writing iCCP instead"); # endif png_write_iCCP(png_ptr, info_ptr->iccp_name, - info_ptr->iccp_profile); + info_ptr->iccp_profile); } # ifdef PNG_WRITE_sRGB_SUPPORTED else @@ -383,7 +383,7 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr) for (i = 0; i < info_ptr->num_text; i++) { png_debug2(2, "Writing trailer text chunk %d, type %d", i, - info_ptr->text[i].compression); + info_ptr->text[i].compression); /* An internationalized chunk? */ if (info_ptr->text[i].compression > 0) { @@ -666,9 +666,9 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1); - png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3); - png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5); + png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1); + png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3); + png_uint_32 s2 = (png_uint_32)(*(rp + 4) << 8) | *(rp + 5); png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL); png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL); *(rp ) = (png_byte)(red >> 8); @@ -693,7 +693,7 @@ png_write_row(png_structrp png_ptr, png_const_bytep row) return; png_debug2(1, "in png_write_row (row %u, pass %d)", - png_ptr->row_number, png_ptr->pass); + png_ptr->row_number, png_ptr->pass); /* Initialize transformations and other stuff if first time */ if (png_ptr->row_number == 0 && png_ptr->pass == 0) @@ -901,7 +901,7 @@ png_set_flush(png_structrp png_ptr, int nrows) if (png_ptr == NULL) return; - png_ptr->flush_dist = (nrows < 0 ? 0 : nrows); + png_ptr->flush_dist = (nrows < 0 ? 0 : (png_uint_32)nrows); } /* Flush the current output buffers now */ @@ -1069,7 +1069,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters) * is not available so the filter can't be used. Just warn here. */ png_app_warning(png_ptr, - "png_set_filter: UP/AVG/PAETH cannot be added after start"); + "png_set_filter: UP/AVG/PAETH cannot be added after start"); filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH); } @@ -1095,13 +1095,13 @@ png_set_filter(png_structrp png_ptr, int method, int filters) if (png_ptr->try_row == NULL) png_ptr->try_row = png_voidcast(png_bytep, - png_malloc(png_ptr, buf_size)); + png_malloc(png_ptr, buf_size)); if (num_filters > 1) { if (png_ptr->tst_row == NULL) png_ptr->tst_row = png_voidcast(png_bytep, - png_malloc(png_ptr, buf_size)); + png_malloc(png_ptr, buf_size)); } } png_ptr->do_filter = (png_byte)filters; @@ -1452,7 +1452,6 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr, #ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED -# ifdef PNG_STDIO_SUPPORTED /* currently required for png_image_write_* */ /* Initialize the write structure - general purpose utility. */ static int png_image_write_init(png_imagep image) @@ -1504,6 +1503,10 @@ typedef struct png_const_voidp first_row; ptrdiff_t row_bytes; png_voidp local_row; + /* Byte count for memory writing */ + png_bytep memory; + png_alloc_size_t memory_bytes; /* not used for STDIO */ + png_alloc_size_t output_bytes; /* running total */ } png_image_write_control; /* Write png_uint_16 input to a 16-bit PNG; the png_ptr has already been set to @@ -1522,7 +1525,8 @@ png_write_image_16bit(png_voidp argument) display->first_row); png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row); png_uint_16p row_end; - const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1; + const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? + 3 : 1; int aindex = 0; png_uint_32 y = image->height; @@ -1536,9 +1540,9 @@ png_write_image_16bit(png_voidp argument) ++output_row; } else - aindex = channels; + aindex = (int)channels; # else - aindex = channels; + aindex = (int)channels; # endif } @@ -1551,7 +1555,7 @@ png_write_image_16bit(png_voidp argument) */ row_end = output_row + image->width * (channels+1); - while (y-- > 0) + for (; y > 0; --y) { png_const_uint_16p in_ptr = input_row; png_uint_16p out_ptr = output_row; @@ -1572,7 +1576,7 @@ png_write_image_16bit(png_voidp argument) if (alpha > 0 && alpha < 65535) reciprocal = ((0xffff<<15)+(alpha>>1))/alpha; - c = channels; + c = (int)channels; do /* always at least one channel */ { png_uint_16 component = *in_ptr++; @@ -1607,7 +1611,7 @@ png_write_image_16bit(png_voidp argument) } png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row)); - input_row += display->row_bytes/(sizeof (png_uint_16)); + input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); } return 1; @@ -1625,7 +1629,7 @@ png_write_image_16bit(png_voidp argument) static png_byte png_unpremultiply(png_uint_32 component, png_uint_32 alpha, - png_uint_32 reciprocal/*from the above macro*/) + png_uint_32 reciprocal/*from the above macro*/) { /* The following gives 1.0 for an alpha of 0, which is fine, otherwise if 0/0 * is represented as some other value there is more likely to be a @@ -1680,7 +1684,8 @@ png_write_image_8bit(png_voidp argument) display->first_row); png_bytep output_row = png_voidcast(png_bytep, display->local_row); png_uint_32 y = image->height; - const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1; + const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? + 3 : 1; if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0) { @@ -1697,12 +1702,12 @@ png_write_image_8bit(png_voidp argument) else # endif - aindex = channels; + aindex = (int)channels; /* Use row_end in place of a loop counter: */ row_end = output_row + image->width * (channels+1); - while (y-- > 0) + for (; y > 0; --y) { png_const_uint_16p in_ptr = input_row; png_bytep out_ptr = output_row; @@ -1720,7 +1725,7 @@ png_write_image_8bit(png_voidp argument) if (alphabyte > 0 && alphabyte < 255) reciprocal = UNP_RECIPROCAL(alpha); - c = channels; + c = (int)channels; do /* always at least one channel */ *out_ptr++ = png_unpremultiply(*in_ptr++, alpha, reciprocal); while (--c > 0); @@ -1732,7 +1737,7 @@ png_write_image_8bit(png_voidp argument) png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row)); - input_row += display->row_bytes/(sizeof (png_uint_16)); + input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); } /* while y */ } @@ -1743,7 +1748,7 @@ png_write_image_8bit(png_voidp argument) */ png_bytep row_end = output_row + image->width * channels; - while (y-- > 0) + for (; y > 0; --y) { png_const_uint_16p in_ptr = input_row; png_bytep out_ptr = output_row; @@ -1757,7 +1762,7 @@ png_write_image_8bit(png_voidp argument) } png_write_row(png_ptr, output_row); - input_row += display->row_bytes/(sizeof (png_uint_16)); + input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); } } @@ -1774,7 +1779,7 @@ png_image_set_PLTE(png_image_write_control *display) /* NOTE: the caller must check for cmap != NULL and entries != 0 */ const png_uint_32 format = image->format; - const int channels = PNG_IMAGE_SAMPLE_CHANNELS(format); + const unsigned int channels = PNG_IMAGE_SAMPLE_CHANNELS(format); # if defined(PNG_FORMAT_BGR_SUPPORTED) &&\ defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED) @@ -1806,7 +1811,7 @@ png_image_set_PLTE(png_image_write_control *display) { png_const_uint_16p entry = png_voidcast(png_const_uint_16p, cmap); - entry += i * channels; + entry += (unsigned int)i * channels; if ((channels & 1) != 0) /* no alpha */ { @@ -1845,16 +1850,16 @@ png_image_set_PLTE(png_image_write_control *display) if (channels >= 3) /* RGB */ { palette[i].blue = png_unpremultiply(entry[afirst + (2 ^ bgr)], - alpha, reciprocal); + alpha, reciprocal); palette[i].green = png_unpremultiply(entry[afirst + 1], alpha, - reciprocal); + reciprocal); palette[i].red = png_unpremultiply(entry[afirst + bgr], alpha, - reciprocal); + reciprocal); } else /* gray */ palette[i].blue = palette[i].red = palette[i].green = - png_unpremultiply(entry[afirst], alpha, reciprocal); + png_unpremultiply(entry[afirst], alpha, reciprocal); } } @@ -1862,7 +1867,7 @@ png_image_set_PLTE(png_image_write_control *display) { png_const_bytep entry = png_voidcast(png_const_bytep, cmap); - entry += i * channels; + entry += (unsigned int)i * channels; switch (channels) { @@ -1901,20 +1906,20 @@ png_image_set_PLTE(png_image_write_control *display) # endif png_set_PLTE(image->opaque->png_ptr, image->opaque->info_ptr, palette, - entries); + entries); if (num_trans > 0) png_set_tRNS(image->opaque->png_ptr, image->opaque->info_ptr, tRNS, - num_trans, NULL); + num_trans, NULL); - image->colormap_entries = entries; + image->colormap_entries = (png_uint_32)entries; } static int png_image_write_main(png_voidp argument) { png_image_write_control *display = png_voidcast(png_image_write_control*, - argument); + argument); png_imagep image = display->image; png_structrp png_ptr = image->opaque->png_ptr; png_inforp info_ptr = image->opaque->info_ptr; @@ -1931,9 +1936,43 @@ png_image_write_main(png_voidp argument) png_set_benign_errors(png_ptr, 0/*error*/); # endif - /* Default the 'row_stride' parameter if required. */ - if (display->row_stride == 0) - display->row_stride = PNG_IMAGE_ROW_STRIDE(*image); + /* Default the 'row_stride' parameter if required, also check the row stride + * and total image size to ensure that they are within the system limits. + */ + { + const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format); + + if (image->width <= 0x7fffffffU/channels) /* no overflow */ + { + png_uint_32 check; + const png_uint_32 png_row_stride = image->width * channels; + + if (display->row_stride == 0) + display->row_stride = (png_int_32)/*SAFE*/png_row_stride; + + if (display->row_stride < 0) + check = (png_uint_32)(-display->row_stride); + + else + check = (png_uint_32)display->row_stride; + + if (check >= png_row_stride) + { + /* Now check for overflow of the image buffer calculation; this + * limits the whole image size to 32 bits for API compatibility with + * the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro. + */ + if (image->height > 0xffffffffU/png_row_stride) + png_error(image->opaque->png_ptr, "memory image too large"); + } + + else + png_error(image->opaque->png_ptr, "supplied row stride too small"); + } + + else + png_error(image->opaque->png_ptr, "image row stride too large"); + } /* Set the required transforms then write the rows in the correct order. */ if ((format & PNG_FORMAT_FLAG_COLORMAP) != 0) @@ -1943,24 +1982,24 @@ png_image_write_main(png_voidp argument) png_uint_32 entries = image->colormap_entries; png_set_IHDR(png_ptr, info_ptr, image->width, image->height, - entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)), - PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + entries > 16 ? 8 : (entries > 4 ? 4 : (entries > 2 ? 2 : 1)), + PNG_COLOR_TYPE_PALETTE, PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); png_image_set_PLTE(display); } else png_error(image->opaque->png_ptr, - "no color-map for color-mapped image"); + "no color-map for color-mapped image"); } else png_set_IHDR(png_ptr, info_ptr, image->width, image->height, - write_16bit ? 16 : 8, - ((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) + - ((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0), - PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); + write_16bit ? 16 : 8, + ((format & PNG_FORMAT_FLAG_COLOR) ? PNG_COLOR_MASK_COLOR : 0) + + ((format & PNG_FORMAT_FLAG_ALPHA) ? PNG_COLOR_MASK_ALPHA : 0), + PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); /* Counter-intuitively the data transformations must be called *after* * png_write_info, not before as in the read code, but the 'set' functions @@ -1975,11 +2014,11 @@ png_image_write_main(png_voidp argument) if ((image->flags & PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB) == 0) png_set_cHRM_fixed(png_ptr, info_ptr, - /* color x y */ - /* white */ 31270, 32900, - /* red */ 64000, 33000, - /* green */ 30000, 60000, - /* blue */ 15000, 6000 + /* color x y */ + /* white */ 31270, 32900, + /* red */ 64000, 33000, + /* green */ 30000, 60000, + /* blue */ 15000, 6000 ); } @@ -2073,7 +2112,7 @@ png_image_write_main(png_voidp argument) (colormap == 0 && display->convert_to_8bit != 0)) { png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr, - png_get_rowbytes(png_ptr, info_ptr))); + png_get_rowbytes(png_ptr, info_ptr))); int result; display->local_row = row; @@ -2099,7 +2138,7 @@ png_image_write_main(png_voidp argument) ptrdiff_t row_bytes = display->row_bytes; png_uint_32 y = image->height; - while (y-- > 0) + for (; y > 0; --y) { png_write_row(png_ptr, row); row += row_bytes; @@ -2110,14 +2149,130 @@ png_image_write_main(png_voidp argument) return 1; } + +static void (PNGCBAPI +image_memory_write)(png_structp png_ptr, png_bytep/*const*/ data, + png_size_t size) +{ + png_image_write_control *display = png_voidcast(png_image_write_control*, + png_ptr->io_ptr/*backdoor: png_get_io_ptr(png_ptr)*/); + const png_alloc_size_t ob = display->output_bytes; + + /* Check for overflow; this should never happen: */ + if (size <= ((png_alloc_size_t)-1) - ob) + { + /* I don't think libpng ever does this, but just in case: */ + if (size > 0) + { + if (display->memory_bytes >= ob+size) /* writing */ + memcpy(display->memory+ob, data, size); + + /* Always update the size: */ + display->output_bytes = ob+size; + } + } + + else + png_error(png_ptr, "png_image_write_to_memory: PNG too big"); +} + +static void (PNGCBAPI +image_memory_flush)(png_structp png_ptr) +{ + PNG_UNUSED(png_ptr) +} + +static int +png_image_write_memory(png_voidp argument) +{ + png_image_write_control *display = png_voidcast(png_image_write_control*, + argument); + + /* The rest of the memory-specific init and write_main in an error protected + * environment. This case needs to use callbacks for the write operations + * since libpng has no built in support for writing to memory. + */ + png_set_write_fn(display->image->opaque->png_ptr, display/*io_ptr*/, + image_memory_write, image_memory_flush); + + return png_image_write_main(display); +} + +int PNGAPI +png_image_write_to_memory(png_imagep image, void *memory, + png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8bit, + const void *buffer, png_int_32 row_stride, const void *colormap) +{ + /* Write the image to the given buffer, or count the bytes if it is NULL */ + if (image != NULL && image->version == PNG_IMAGE_VERSION) + { + if (memory_bytes != NULL && buffer != NULL) + { + /* This is to give the caller an easier error detection in the NULL + * case and guard against uninitialized variable problems: + */ + if (memory == NULL) + *memory_bytes = 0; + + if (png_image_write_init(image) != 0) + { + png_image_write_control display; + int result; + + memset(&display, 0, (sizeof display)); + display.image = image; + display.buffer = buffer; + display.row_stride = row_stride; + display.colormap = colormap; + display.convert_to_8bit = convert_to_8bit; + display.memory = png_voidcast(png_bytep, memory); + display.memory_bytes = *memory_bytes; + display.output_bytes = 0; + + result = png_safe_execute(image, png_image_write_memory, &display); + png_image_free(image); + + /* write_memory returns true even if we ran out of buffer. */ + if (result) + { + /* On out-of-buffer this function returns '0' but still updates + * memory_bytes: + */ + if (memory != NULL && display.output_bytes > *memory_bytes) + result = 0; + + *memory_bytes = display.output_bytes; + } + + return result; + } + + else + return 0; + } + + else + return png_image_error(image, + "png_image_write_to_memory: invalid argument"); + } + + else if (image != NULL) + return png_image_error(image, + "png_image_write_to_memory: incorrect PNG_IMAGE_VERSION"); + + else + return 0; +} + +#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED int PNGAPI png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit, - const void *buffer, png_int_32 row_stride, const void *colormap) + const void *buffer, png_int_32 row_stride, const void *colormap) { /* Write the image to the given (FILE*). */ if (image != NULL && image->version == PNG_IMAGE_VERSION) { - if (file != NULL) + if (file != NULL && buffer != NULL) { if (png_image_write_init(image) != 0) { @@ -2148,12 +2303,12 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit, else return png_image_error(image, - "png_image_write_to_stdio: invalid argument"); + "png_image_write_to_stdio: invalid argument"); } else if (image != NULL) return png_image_error(image, - "png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION"); + "png_image_write_to_stdio: incorrect PNG_IMAGE_VERSION"); else return 0; @@ -2161,20 +2316,20 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit, int PNGAPI png_image_write_to_file(png_imagep image, const char *file_name, - int convert_to_8bit, const void *buffer, png_int_32 row_stride, - const void *colormap) + int convert_to_8bit, const void *buffer, png_int_32 row_stride, + const void *colormap) { /* Write the image to the named file. */ if (image != NULL && image->version == PNG_IMAGE_VERSION) { - if (file_name != NULL) + if (file_name != NULL && buffer != NULL) { FILE *fp = fopen(file_name, "wb"); if (fp != NULL) { if (png_image_write_to_stdio(image, fp, convert_to_8bit, buffer, - row_stride, colormap) != 0) + row_stride, colormap) != 0) { int error; /* from fflush/fclose */ @@ -2215,16 +2370,16 @@ png_image_write_to_file(png_imagep image, const char *file_name, else return png_image_error(image, - "png_image_write_to_file: invalid argument"); + "png_image_write_to_file: invalid argument"); } else if (image != NULL) return png_image_error(image, - "png_image_write_to_file: incorrect PNG_IMAGE_VERSION"); + "png_image_write_to_file: incorrect PNG_IMAGE_VERSION"); else return 0; } -# endif /* STDIO */ +#endif /* SIMPLIFIED_WRITE_STDIO */ #endif /* SIMPLIFIED_WRITE */ #endif /* WRITE */ diff --git a/src/3rdparty/libpng/pngwtran.c b/src/3rdparty/libpng/pngwtran.c index 5dc949157d..377b43e5ca 100644 --- a/src/3rdparty/libpng/pngwtran.c +++ b/src/3rdparty/libpng/pngwtran.c @@ -1,8 +1,8 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * Last changed in libpng 1.6.18 [July 23, 2015] - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -177,7 +177,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, if (row_info->color_type != PNG_COLOR_TYPE_PALETTE) { int shift_start[4], shift_dec[4]; - int channels = 0; + unsigned int channels = 0; if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) { @@ -525,7 +525,7 @@ png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info) #ifdef PNG_WRITE_FILLER_SUPPORTED if ((png_ptr->transformations & PNG_FILLER) != 0) png_do_strip_channel(row_info, png_ptr->row_buf + 1, - !(png_ptr->flags & PNG_FLAG_FILLER_AFTER)); + !(png_ptr->flags & PNG_FLAG_FILLER_AFTER)); #endif #ifdef PNG_WRITE_PACKSWAP_SUPPORTED @@ -549,7 +549,7 @@ png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info) #ifdef PNG_WRITE_SHIFT_SUPPORTED if ((png_ptr->transformations & PNG_SHIFT) != 0) png_do_shift(row_info, png_ptr->row_buf + 1, - &(png_ptr->shift)); + &(png_ptr->shift)); #endif #ifdef PNG_WRITE_SWAP_ALPHA_SUPPORTED diff --git a/src/3rdparty/libpng/pngwutil.c b/src/3rdparty/libpng/pngwutil.c index 0ee102b5fb..d1a82d45e1 100644 --- a/src/3rdparty/libpng/pngwutil.c +++ b/src/3rdparty/libpng/pngwutil.c @@ -1,8 +1,8 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.6.19 [November 12, 2015] - * Copyright (c) 1998-2015 Glenn Randers-Pehrson + * Last changed in libpng 1.6.26 [October 20, 2016] + * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * @@ -23,10 +23,10 @@ void PNGAPI png_save_uint_32(png_bytep buf, png_uint_32 i) { - buf[0] = (png_byte)(i >> 24); - buf[1] = (png_byte)(i >> 16); - buf[2] = (png_byte)(i >> 8); - buf[3] = (png_byte)(i ); + buf[0] = (png_byte)((i >> 24) & 0xffU); + buf[1] = (png_byte)((i >> 16) & 0xffU); + buf[2] = (png_byte)((i >> 8) & 0xffU); + buf[3] = (png_byte)( i & 0xffU); } /* Place a 16-bit number into a buffer in PNG byte order. @@ -36,8 +36,8 @@ png_save_uint_32(png_bytep buf, png_uint_32 i) void PNGAPI png_save_uint_16(png_bytep buf, unsigned int i) { - buf[0] = (png_byte)(i >> 8); - buf[1] = (png_byte)(i ); + buf[0] = (png_byte)((i >> 8) & 0xffU); + buf[1] = (png_byte)( i & 0xffU); } #endif @@ -59,7 +59,7 @@ png_write_sig(png_structrp png_ptr) /* Write the rest of the 8 byte signature */ png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], - (png_size_t)(8 - png_ptr->sig_bytes)); + (png_size_t)(8 - png_ptr->sig_bytes)); if (png_ptr->sig_bytes < 3) png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; @@ -174,7 +174,7 @@ png_write_chunk_end(png_structrp png_ptr) */ static void png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name, - png_const_bytep data, png_size_t length) + png_const_bytep data, png_size_t length) { if (png_ptr == NULL) return; @@ -191,10 +191,10 @@ png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name, /* This is the API that calls the internal function above. */ void PNGAPI png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string, - png_const_bytep data, png_size_t length) + png_const_bytep data, png_size_t length) { png_write_complete_chunk(png_ptr, PNG_CHUNK_FROM_STRING(chunk_string), data, - length); + length); } /* This is used below to find the size of an image to pass to png_deflate_claim, @@ -291,7 +291,7 @@ optimize_cmf(png_bytep data, png_alloc_size_t data_size) /* Initialize the compressor for the appropriate type of compression. */ static int png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, - png_alloc_size_t data_size) + png_alloc_size_t data_size) { if (png_ptr->zowner != 0) { @@ -408,7 +408,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, png_ptr->zstream.avail_out = 0; /* Now initialize if required, setting the new parameters, otherwise just - * to a simple reset to the previous parameters. + * do a simple reset to the previous parameters. */ if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0) ret = deflateReset(&png_ptr->zstream); @@ -416,7 +416,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner, else { ret = deflateInit2(&png_ptr->zstream, level, method, windowBits, - memLevel, strategy); + memLevel, strategy); if (ret == Z_OK) png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED; @@ -477,7 +477,7 @@ typedef struct static void png_text_compress_init(compression_state *comp, png_const_bytep input, - png_alloc_size_t input_len) + png_alloc_size_t input_len) { comp->input = input; comp->input_len = input_len; @@ -487,7 +487,7 @@ png_text_compress_init(compression_state *comp, png_const_bytep input, /* Compress the data in the compression state input */ static int png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name, - compression_state *comp, png_uint_32 prefix_len) + compression_state *comp, png_uint_32 prefix_len) { int ret; @@ -579,7 +579,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name, /* Compress the data */ ret = deflate(&png_ptr->zstream, - input_len > 0 ? Z_NO_FLUSH : Z_FINISH); + input_len > 0 ? Z_NO_FLUSH : Z_FINISH); /* Claw back input data that was not consumed (because avail_in is * reset above every time round the loop). @@ -665,90 +665,6 @@ png_write_compressed_data_out(png_structrp png_ptr, compression_state *comp) } #endif /* WRITE_COMPRESSED_TEXT */ -#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \ - defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED) -/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification, - * and if invalid, correct the keyword rather than discarding the entire - * chunk. The PNG 1.0 specification requires keywords 1-79 characters in - * length, forbids leading or trailing whitespace, multiple internal spaces, - * and the non-break space (0x80) from ISO 8859-1. Returns keyword length. - * - * The 'new_key' buffer must be 80 characters in size (for the keyword plus a - * trailing '\0'). If this routine returns 0 then there was no keyword, or a - * valid one could not be generated, and the caller must png_error. - */ -static png_uint_32 -png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key) -{ - png_const_charp orig_key = key; - png_uint_32 key_len = 0; - int bad_character = 0; - int space = 1; - - png_debug(1, "in png_check_keyword"); - - if (key == NULL) - { - *new_key = 0; - return 0; - } - - while (*key && key_len < 79) - { - png_byte ch = (png_byte)*key++; - - if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/)) - *new_key++ = ch, ++key_len, space = 0; - - else if (space == 0) - { - /* A space or an invalid character when one wasn't seen immediately - * before; output just a space. - */ - *new_key++ = 32, ++key_len, space = 1; - - /* If the character was not a space then it is invalid. */ - if (ch != 32) - bad_character = ch; - } - - else if (bad_character == 0) - bad_character = ch; /* just skip it, record the first error */ - } - - if (key_len > 0 && space != 0) /* trailing space */ - { - --key_len, --new_key; - if (bad_character == 0) - bad_character = 32; - } - - /* Terminate the keyword */ - *new_key = 0; - - if (key_len == 0) - return 0; - -#ifdef PNG_WARNINGS_SUPPORTED - /* Try to only output one warning per keyword: */ - if (*key != 0) /* keyword too long */ - png_warning(png_ptr, "keyword truncated"); - - else if (bad_character != 0) - { - PNG_WARNING_PARAMETERS(p) - - png_warning_parameter(p, 1, orig_key); - png_warning_parameter_signed(p, 2, PNG_NUMBER_FORMAT_02x, bad_character); - - png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'"); - } -#endif /* WARNINGS */ - - return key_len; -} -#endif /* WRITE_TEXT || WRITE_pCAL || WRITE_iCCP || WRITE_sPLT */ - /* Write the IHDR chunk, and update the png_struct with the necessary * information. Note that the rest of this code depends upon this * information being correct. @@ -1009,7 +925,7 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette, */ void /* PRIVATE */ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input, - png_alloc_size_t input_len, int flush) + png_alloc_size_t input_len, int flush) { if (png_ptr->zowner != png_IDAT) { @@ -1021,7 +937,7 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input, if (png_ptr->zbuffer_list == NULL) { png_ptr->zbuffer_list = png_voidcast(png_compression_bufferp, - png_malloc(png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr))); + png_malloc(png_ptr, PNG_COMPRESSION_BUFFER_SIZE(png_ptr))); png_ptr->zbuffer_list->next = NULL; } @@ -1260,7 +1176,7 @@ png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette) png_byte new_name[80]; png_byte entrybuf[10]; png_size_t entry_size = (spalette->depth == 8 ? 6 : 10); - png_size_t palette_size = entry_size * spalette->nentries; + png_size_t palette_size = entry_size * (png_size_t)spalette->nentries; png_sPLT_entryp ep; #ifndef PNG_POINTER_INDEXING_SUPPORTED int i; @@ -1442,7 +1358,7 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha, /* Write the chunk out as it is */ png_write_complete_chunk(png_ptr, png_tRNS, trans_alpha, - (png_size_t)num_trans); + (png_size_t)num_trans); } else if (color_type == PNG_COLOR_TYPE_GRAY) @@ -1473,7 +1389,7 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha, #endif { png_app_warning(png_ptr, - "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); + "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); return; } @@ -1525,7 +1441,8 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type) #endif { png_warning(png_ptr, - "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); + "Ignoring attempt to write 16-bit bKGD chunk " + "when bit_depth is 8"); return; } @@ -1655,7 +1572,7 @@ png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text, /* Compute the compressed data; do it now for the length */ png_text_compress_init(&comp, (png_const_bytep)text, - text == NULL ? 0 : strlen(text)); + text == NULL ? 0 : strlen(text)); if (png_text_compress(png_ptr, png_zTXt, &comp, key_len) != Z_OK) png_error(png_ptr, png_ptr->zstream.msg); @@ -1826,7 +1743,7 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0, total_len = purpose_len + units_len + 10; params_len = (png_size_tp)png_malloc(png_ptr, - (png_alloc_size_t)(nparams * (sizeof (png_size_t)))); + (png_alloc_size_t)((png_alloc_size_t)nparams * (sizeof (png_size_t)))); /* Find the length of each parameter, making sure we don't count the * null terminator for the last parameter. @@ -2025,7 +1942,7 @@ png_write_start_row(png_structrp png_ptr) */ if ((filters & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) != 0) png_ptr->prev_row = png_voidcast(png_bytep, - png_calloc(png_ptr, buf_size)); + png_calloc(png_ptr, buf_size)); #endif /* WRITE_FILTER */ #ifdef PNG_WRITE_INTERLACING_SUPPORTED @@ -2328,7 +2245,7 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) */ static void /* PRIVATE */ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, - png_size_t row_bytes); + png_size_t row_bytes); #ifdef PNG_WRITE_FILTER_SUPPORTED static png_size_t /* PRIVATE */ @@ -2338,7 +2255,7 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp, png_bytep rp, dp, lp; png_size_t i; png_size_t sum = 0; - int v; + unsigned int v; png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB; @@ -2346,14 +2263,22 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp, i++, rp++, dp++) { v = *dp = *rp; +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif } for (lp = png_ptr->row_buf + 1; i < row_bytes; i++, rp++, lp++, dp++) { v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif if (sum > lmins) /* We are already worse, don't continue. */ break; @@ -2362,6 +2287,28 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp, return (sum); } +static void /* PRIVATE */ +png_setup_sub_row_only(png_structrp png_ptr, const png_uint_32 bpp, + const png_size_t row_bytes) +{ + png_bytep rp, dp, lp; + png_size_t i; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp; + i++, rp++, dp++) + { + *dp = *rp; + } + + for (lp = png_ptr->row_buf + 1; i < row_bytes; + i++, rp++, lp++, dp++) + { + *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff); + } +} + static png_size_t /* PRIVATE */ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes, const png_size_t lmins) @@ -2369,7 +2316,7 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes, png_bytep rp, dp, pp; png_size_t i; png_size_t sum = 0; - int v; + unsigned int v; png_ptr->try_row[0] = PNG_FILTER_VALUE_UP; @@ -2378,7 +2325,11 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes, i++, rp++, pp++, dp++) { v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif if (sum > lmins) /* We are already worse, don't continue. */ break; @@ -2386,24 +2337,43 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes, return (sum); } +static void /* PRIVATE */ +png_setup_up_row_only(png_structrp png_ptr, const png_size_t row_bytes) +{ + png_bytep rp, dp, pp; + png_size_t i; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_UP; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, + pp = png_ptr->prev_row + 1; i < row_bytes; + i++, rp++, pp++, dp++) + { + *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff); + } +} static png_size_t /* PRIVATE */ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp, - const png_size_t row_bytes, const png_size_t lmins) + const png_size_t row_bytes, const png_size_t lmins) { png_bytep rp, dp, pp, lp; png_uint_32 i; png_size_t sum = 0; - int v; + unsigned int v; png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG; for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, - pp = png_ptr->prev_row + 1; i < bpp; i++) + pp = png_ptr->prev_row + 1; i < bpp; i++) { v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif } for (lp = png_ptr->row_buf + 1; i < row_bytes; i++) @@ -2411,7 +2381,11 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp, v = *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) & 0xff); +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif if (sum > lmins) /* We are already worse, don't continue. */ break; @@ -2419,6 +2393,27 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp, return (sum); } +static void /* PRIVATE */ +png_setup_avg_row_only(png_structrp png_ptr, const png_uint_32 bpp, + const png_size_t row_bytes) +{ + png_bytep rp, dp, pp, lp; + png_uint_32 i; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, + pp = png_ptr->prev_row + 1; i < bpp; i++) + { + *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff); + } + + for (lp = png_ptr->row_buf + 1; i < row_bytes; i++) + { + *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2)) + & 0xff); + } +} static png_size_t /* PRIVATE */ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp, @@ -2427,7 +2422,7 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp, png_bytep rp, dp, pp, cp, lp; png_size_t i; png_size_t sum = 0; - int v; + unsigned int v; png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH; @@ -2436,7 +2431,11 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp, { v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif } for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes; @@ -2465,7 +2464,11 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp, v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif if (sum > lmins) /* We are already worse, don't continue. */ break; @@ -2473,6 +2476,48 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp, return (sum); } +static void /* PRIVATE */ +png_setup_paeth_row_only(png_structrp png_ptr, const png_uint_32 bpp, + const png_size_t row_bytes) +{ + png_bytep rp, dp, pp, cp, lp; + png_size_t i; + + png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH; + + for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1, + pp = png_ptr->prev_row + 1; i < bpp; i++) + { + *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff); + } + + for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes; + i++) + { + int a, b, c, pa, pb, pc, p; + + b = *pp++; + c = *cp++; + a = *lp++; + + p = b - c; + pc = a - c; + +#ifdef PNG_USE_ABS + pa = abs(p); + pb = abs(pc); + pc = abs(p + pc); +#else + pa = p < 0 ? -p : p; + pb = pc < 0 ? -pc : pc; + pc = (p + pc) < 0 ? -(p + pc) : p + pc; +#endif + + p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; + + *dp++ = (png_byte)(((int)*rp++ - p) & 0xff); + } +} #endif /* WRITE_FILTER */ void /* PRIVATE */ @@ -2481,7 +2526,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) #ifndef PNG_WRITE_FILTER_SUPPORTED png_write_filtered_row(png_ptr, png_ptr->row_buf, row_info->rowbytes+1); #else - png_byte filter_to_do = png_ptr->do_filter; + unsigned int filter_to_do = png_ptr->do_filter; png_bytep row_buf; png_bytep best_row; png_uint_32 bpp; @@ -2527,32 +2572,33 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) */ best_row = png_ptr->row_buf; - - if ((filter_to_do & PNG_FILTER_NONE) != 0 && filter_to_do != PNG_FILTER_NONE) + if (PNG_SIZE_MAX/128 <= row_bytes) + { + /* Overflow can occur in the calculation, just select the lowest set + * filter. + */ + filter_to_do &= 0U-filter_to_do; + } + else if ((filter_to_do & PNG_FILTER_NONE) != 0 && + filter_to_do != PNG_FILTER_NONE) { + /* Overflow not possible and multiple filters in the list, including the + * 'none' filter. + */ png_bytep rp; png_size_t sum = 0; png_size_t i; - int v; + unsigned int v; - if (PNG_SIZE_MAX/128 <= row_bytes) - { - for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) - { - /* Check for overflow */ - if (sum > PNG_SIZE_MAX/128 - 256) - break; - - v = *rp; - sum += (v < 128) ? v : 256 - v; - } - } - else /* Overflow is not possible */ { for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++) { v = *rp; +#ifdef PNG_USE_ABS + sum += 128 - abs((int)v - 128); +#else sum += (v < 128) ? v : 256 - v; +#endif } } @@ -2563,7 +2609,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) if (filter_to_do == PNG_FILTER_SUB) /* It's the only filter so no testing is needed */ { - (void) png_setup_sub_row(png_ptr, bpp, row_bytes, mins); + png_setup_sub_row_only(png_ptr, bpp, row_bytes); best_row = png_ptr->try_row; } @@ -2589,7 +2635,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Up filter */ if (filter_to_do == PNG_FILTER_UP) { - (void) png_setup_up_row(png_ptr, row_bytes, mins); + png_setup_up_row_only(png_ptr, row_bytes); best_row = png_ptr->try_row; } @@ -2615,7 +2661,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Avg filter */ if (filter_to_do == PNG_FILTER_AVG) { - (void) png_setup_avg_row(png_ptr, bpp, row_bytes, mins); + png_setup_avg_row_only(png_ptr, bpp, row_bytes); best_row = png_ptr->try_row; } @@ -2639,9 +2685,9 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) } /* Paeth filter */ - if ((filter_to_do == PNG_FILTER_PAETH) != 0) + if (filter_to_do == PNG_FILTER_PAETH) { - (void) png_setup_paeth_row(png_ptr, bpp, row_bytes, mins); + png_setup_paeth_row_only(png_ptr, bpp, row_bytes); best_row = png_ptr->try_row; } @@ -2673,7 +2719,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info) /* Do the actual writing of a previously filtered row. */ static void png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row, - png_size_t full_row_length/*includes filter byte*/) + png_size_t full_row_length/*includes filter byte*/) { png_debug(1, "in png_write_filtered_row"); diff --git a/src/3rdparty/libpng/qt_attribution.json b/src/3rdparty/libpng/qt_attribution.json index 93e73243af..5affffd298 100644 --- a/src/3rdparty/libpng/qt_attribution.json +++ b/src/3rdparty/libpng/qt_attribution.json @@ -6,10 +6,29 @@ "Description": "libpng is the official PNG reference library.", "Homepage": "http://www.libpng.org/pub/png/libpng.html", + "Version": "1.6.28", "License": "libpng License", "LicenseId": "Libpng", "LicenseFile": "LICENSE", - "Copyright": "Copyright (c) 1998-2015 Glenn Randers-Pehrson + "Copyright": "Copyright (c) 1998-2017 Glenn Randers-Pehrson +Copyright (c) 2000-2017 Simon-Pierre Cadieux +Copyright (c) 2000-2017 Eric S. Raymond +Copyright (c) 2000-2017 Mans Rullgard +Copyright (c) 2000-2017 Cosmin Truta +Copyright (c) 2000-2017 Gilles Vollant +Copyright (c) 2000-2017 James Yu +Copyright (c) 2000-2017 Mandar Sahastrabuddhe +Copyright (c) 1998-2000 Tom Lane +Copyright (c) 1998-2000 Willem van Schaik Copyright (c) 1996-1997 Andreas Dilger +Copyright (c) 1996-1997 John Bowler +Copyright (c) 1996-1997 Kevin Bracey +Copyright (c) 1996-1997 Sam Bushell +Copyright (c) 1996-1997 Magnus Holmgren +Copyright (c) 1996-1997 Greg Roelofs +Copyright (c) 1996-1997 Tom Tanner +Copyright (c) 1995-1996 Dave Martindale +Copyright (c) 1995-1996 Paul Schmidt +Copyright (c) 1995-1996 Tim Wegner Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." } -- cgit v1.2.3 From 14f09643441cc2938dc2791e790f6309ab12cb1d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 19 Sep 2016 13:13:44 -0700 Subject: QVariant: don't do fuzzy comparisons with NaN and infinities There was a test that tested this, but was wrong. [ChangeLog][QtCore][QVariant] Fixed a bug that caused wrong results for comparisons of QVariants containing either NaN or infinite numbers. Task-number: QTBUG-56073 Change-Id: I33dc971f005a4848bb8ffffd1475d29d00dd1b7f Reviewed-by: Edward Welbourne Reviewed-by: Thiago Macieira --- src/corelib/kernel/qvariant.cpp | 12 +++++++++++- tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp | 15 +++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 9476ab3f5b..7c9df5b46f 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -74,6 +74,7 @@ #include "qline.h" #endif +#include #include #include @@ -3472,8 +3473,17 @@ static int numericCompare(const QVariant::Private *d1, const QVariant::Private * Q_ASSERT(ok); qreal r2 = qConvertToRealNumber(d2, &ok); Q_ASSERT(ok); - if (r1 == r2 || qFuzzyCompare(r1, r2)) + if (r1 == r2) return 0; + + // only do fuzzy comparisons for finite, non-zero numbers + int c1 = std::fpclassify(r1); + int c2 = std::fpclassify(r2); + if ((c1 == FP_NORMAL || c1 == FP_SUBNORMAL) && (c2 == FP_NORMAL || c2 == FP_SUBNORMAL)) { + if (qFuzzyCompare(r1, r2)) + return 0; + } + return r1 < r2 ? -1 : 1; } diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 3a51e67768..442f7e80d1 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -1755,6 +1755,10 @@ void tst_QVariant::compareNumbers_data() const QTest::newRow("double5") << qVariantFromValue(0.) << qVariantFromValue(-qInf()) << +1; QTest::newRow("double6") << qVariantFromValue(-double(qInf())) << qVariantFromValue(-qInf()) << 0; QTest::newRow("double7") << qVariantFromValue(qInf()) << qVariantFromValue(qInf()) << 0; + QTest::newRow("double8") << qVariantFromValue(-qInf()) << qVariantFromValue(qInf()) << -1; + QTest::newRow("double9") << qVariantFromValue(qQNaN()) << qVariantFromValue(0.) << INT_MAX; + QTest::newRow("double10") << qVariantFromValue(0.) << qVariantFromValue(qQNaN()) << INT_MAX; + QTest::newRow("double11") << qVariantFromValue(qQNaN()) << qVariantFromValue(qQNaN()) << INT_MAX; // mixed comparisons // fp + fp @@ -1763,8 +1767,12 @@ void tst_QVariant::compareNumbers_data() const QTest::newRow("float+double3") << qVariantFromValue(0.f) << qVariantFromValue(-1.) << +1; QTest::newRow("float+double4") << qVariantFromValue(-float(qInf())) << qVariantFromValue(0.) << -1; QTest::newRow("float+double5") << qVariantFromValue(0.f) << qVariantFromValue(-qInf()) << +1; - QTest::newRow("float+double6") << qVariantFromValue(-float(qInf())) << qVariantFromValue(qInf()) << 0; + QTest::newRow("float+double6") << qVariantFromValue(-float(qInf())) << qVariantFromValue(-qInf()) << 0; QTest::newRow("float+double7") << qVariantFromValue(float(qInf())) << qVariantFromValue(qInf()) << 0; + QTest::newRow("float+double8") << qVariantFromValue(-float(qInf())) << qVariantFromValue(qInf()) << -1; + QTest::newRow("float+double9") << qVariantFromValue(qQNaN()) << qVariantFromValue(0.) << INT_MAX; + QTest::newRow("float+double10") << qVariantFromValue(0.) << qVariantFromValue(qQNaN()) << INT_MAX; + QTest::newRow("float+double11") << qVariantFromValue(qQNaN()) << qVariantFromValue(qQNaN()) << INT_MAX; // fp + int QTest::newRow("float+int1") << qVariantFromValue(0.f) << qVariantFromValue(0) << 0; @@ -1978,7 +1986,7 @@ void tst_QVariant::compareNumbers() const QCOMPARE(v2, v1); QVERIFY(v2 >= v1); QVERIFY(!(v2 > v1)); - } else { + } else if (expected == +1) { QVERIFY(!(v1 < v2)); QVERIFY(!(v1 <= v2)); QVERIFY(!(v1 == v2)); @@ -1990,6 +1998,9 @@ void tst_QVariant::compareNumbers() const QVERIFY(!(v2 == v1)); QVERIFY(!(v2 >= v1)); QVERIFY(!(v2 > v1)); + } else { + // unorderable (NaN) + QVERIFY(!(v1 == v2)); } } -- cgit v1.2.3 From 71b54cc24431e8bc6e97f5d62132bd5261764c3a Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 15 Dec 2016 20:27:47 -0800 Subject: QtCore & winmain: Remove dead code The last use of qWinMain was removed in commit 390598cb4392bbf5f77e8a05578e190b1a9f544a, "Winmain: Remove Windows CE." It used to be used on non-WinCE, but that was dropped in commit 9b121e5579538477a1fc7c8250e5d7e875a58de8. Change-Id: Idc347fbb462f4122b044fffd1490a210358a61b1 Reviewed-by: Friedemann Kleint --- src/corelib/kernel/qcoreapplication_win.cpp | 27 --------------------------- src/winmain/qtmain_win.cpp | 9 +-------- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index 67e509eeef..a9ca82c757 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -148,33 +148,6 @@ Q_CORE_EXPORT int qWinAppCmdShow() // get main window sho } #endif -/***************************************************************************** - qWinMain() - Initializes Windows. Called from WinMain() in qtmain_win.cpp - *****************************************************************************/ - -#if !defined(Q_OS_WINRT) - -// ### Qt6: FIXME: Consider removing this function. It is here for Active Qt -// servers and for binary for compatibility to applications built with Qt 5.3 -// using qtmain.lib which calls it In Qt 5.4, qtmain.lib was changed to use -// CommandLineToArgvW() without calling into Qt5Core. -Q_CORE_EXPORT -void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, - int cmdShow, int &argc, QVector &argv) -{ - Q_UNUSED(instance) - Q_UNUSED(prevInstance) - Q_UNUSED(cmdShow) - - const QStringList wArgv = qWinCmdArgs(QString::fromLocal8Bit(cmdParam)); - argv.clear(); - argc = wArgv.size(); - for (const QString &wArg : wArgv) - argv.append(_strdup(wArg.toLocal8Bit().constData())); -} - -#endif // !Q_OS_WINRT - #ifndef QT_NO_QOBJECT #if defined(Q_OS_WIN) && !defined(QT_NO_DEBUG_STREAM) diff --git a/src/winmain/qtmain_win.cpp b/src/winmain/qtmain_win.cpp index 7087176110..5f90055762 100644 --- a/src/winmain/qtmain_win.cpp +++ b/src/winmain/qtmain_win.cpp @@ -61,16 +61,9 @@ linking to the Qt DLL. When a Windows application starts, the WinMain function is - invoked. WinMain calls qWinMain in the Qt DLL/library, which - initializes Qt. + invoked. */ -QT_BEGIN_NAMESPACE - -extern void qWinMain(HINSTANCE, HINSTANCE, LPSTR, int, int &, QVector &); - -QT_END_NAMESPACE - QT_USE_NAMESPACE -- cgit v1.2.3 From b7247ac9452e73a405cdc4efc0796fd6240155a3 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 26 Jan 2017 14:47:40 -0800 Subject: linux-icc: Remove -falign-functions=16 There's no reason to have that. Let the compiler decide whether it wants to align or not. Current versions seem not to want to align beyond multiple of 2. Change-Id: Iab7c358838e1487387a2fffd149d73e0a218d3c2 Reviewed-by: Dominik Haumann Reviewed-by: Oswald Buddenhagen Reviewed-by: Thiago Macieira --- mkspecs/linux-icc/qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/linux-icc/qmake.conf b/mkspecs/linux-icc/qmake.conf index 8ca2767061..4822d2a0e0 100644 --- a/mkspecs/linux-icc/qmake.conf +++ b/mkspecs/linux-icc/qmake.conf @@ -16,7 +16,7 @@ QMAKE_CFLAGS_APP = -fPIC QMAKE_CFLAGS_DEPS = -M QMAKE_CFLAGS_WARN_ON = -w1 -Wall -Wcheck -wd1572,873,2259,2261,3373 QMAKE_CFLAGS_WARN_OFF = -w -QMAKE_CFLAGS_RELEASE = -O2 -falign-functions=16 -ansi-alias -fstrict-aliasing +QMAKE_CFLAGS_RELEASE = -O2 -ansi-alias -fstrict-aliasing QMAKE_CFLAGS_DEBUG = -O0 -g QMAKE_CFLAGS_SHLIB = -fPIC QMAKE_CFLAGS_STATIC_LIB = $$QMAKE_CFLAGS_SHLIB -- cgit v1.2.3 From b9e82f206c8c5ab3753d851252a68dd1b328aa05 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 26 Aug 2016 08:03:34 -0700 Subject: Mark Clang 4.0 as warning-free Change-Id: If337c17c98844a98b196fffd146e63c38ce1ee7b Reviewed-by: Lars Knoll --- mkspecs/features/qt_common.prf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf index 2dfc22f16e..eaea8f2d4b 100644 --- a/mkspecs/features/qt_common.prf +++ b/mkspecs/features/qt_common.prf @@ -70,10 +70,10 @@ warnings_are_errors:warning_clean { # compiler. clang { # Apple clang 4.0-4.2,5.0-5.1,6.0-6.4,7.0-7.3 - # Regular clang 3.3-3.9 + # Regular clang 3.3-3.9, 4.0 apple_ver = $${QT_APPLE_CLANG_MAJOR_VERSION}.$${QT_APPLE_CLANG_MINOR_VERSION} reg_ver = $${QT_CLANG_MAJOR_VERSION}.$${QT_CLANG_MINOR_VERSION} - contains(apple_ver, "4\\.[012]|5\\.[01]|6\\.[01234]|7\\.[0123]")|contains(reg_ver, "3\\.[3-9]") { + contains(apple_ver, "4\\.[012]|5\\.[01]|6\\.[01234]|7\\.[0123]")|contains(reg_ver, "3\\.[3-9]|4\\.0") { QMAKE_CXXFLAGS_WARN_ON += -Werror -Wno-error=\\$${LITERAL_HASH}warnings -Wno-error=deprecated-declarations $$WERROR } } else:intel_icc:linux { -- cgit v1.2.3 From 3d0f62de8be9af8b406c889b68707448cb2d2b18 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 1 Dec 2016 07:46:40 -0800 Subject: qnumeric_p.h: Simplify code to match currently-supported platforms MSVC < 1800 (older than 2013) is no longer supported, so we can simplify the code. And the implementation for C never worked -- "if it's not C++, let's use a namespace!" Change-Id: Iaeecaffe26af4535b416fffd148c2c6788c43881 Reviewed-by: Friedemann Kleint Reviewed-by: Erik Verbruggen --- src/corelib/global/qnumeric_p.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/src/corelib/global/qnumeric_p.h b/src/corelib/global/qnumeric_p.h index 01b8772ee1..06658b422d 100644 --- a/src/corelib/global/qnumeric_p.h +++ b/src/corelib/global/qnumeric_p.h @@ -66,7 +66,7 @@ #include #endif -#if !defined(Q_CC_MSVC) && (defined(Q_OS_QNX) || defined(Q_CC_INTEL) || !defined(__cplusplus)) +#if !defined(Q_CC_MSVC) && (defined(Q_OS_QNX) || defined(Q_CC_INTEL)) # include # ifdef isnan # define QT_MATH_H_DEFINES_MACROS @@ -92,14 +92,7 @@ QT_END_NAMESPACE QT_BEGIN_NAMESPACE namespace qnumeric_std_wrapper { -#if defined(Q_CC_MSVC) && _MSC_VER < 1800 -static inline bool isnan(double d) { return !!_isnan(d); } -static inline bool isinf(double d) { return !_finite(d) && !_isnan(d); } -static inline bool isfinite(double d) { return !!_finite(d); } -static inline bool isnan(float f) { return !!_isnan(f); } -static inline bool isinf(float f) { return !_finite(f) && !_isnan(f); } -static inline bool isfinite(float f) { return !!_finite(f); } -#elif defined(QT_MATH_H_DEFINES_MACROS) +#if defined(QT_MATH_H_DEFINES_MACROS) # undef QT_MATH_H_DEFINES_MACROS static inline bool isnan(double d) { return math_h_isnan(d); } static inline bool isinf(double d) { return math_h_isinf(d); } -- cgit v1.2.3 From 796517b589809caeff9098dac166517b5ab858ac Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 19 Jan 2017 14:13:31 -0800 Subject: win32/default_pre.prf: remove unused incremental_off CONFIG Nothing uses this and there's no incremental_off.prf since the MSVC6 purge in 99f390f9 (dec 2009). Change-Id: I2bc52f3c7a574209b213fffd149b4bf378805969 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/win32/default_pre.prf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkspecs/features/win32/default_pre.prf b/mkspecs/features/win32/default_pre.prf index a9b247e113..4bd1653aee 100644 --- a/mkspecs/features/win32/default_pre.prf +++ b/mkspecs/features/win32/default_pre.prf @@ -1,2 +1,2 @@ -CONFIG = incremental_off windows $$CONFIG +CONFIG = windows $$CONFIG load(default_pre) -- cgit v1.2.3 From 681c15891e723925a876f5d3e8d711b503384285 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 31 Jan 2017 21:15:56 +0100 Subject: Fix \since for QDrag::cancel() This was added in 5.7.0 alpha, not 5.6. Change-Id: Id8c68eca806274c77e7fa6904f21224fb468c8e4 Reviewed-by: Friedemann Kleint --- src/gui/kernel/qdrag.cpp | 2 +- src/gui/kernel/qplatformdrag.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp index 5b36f496f1..0aadac2c62 100644 --- a/src/gui/kernel/qdrag.cpp +++ b/src/gui/kernel/qdrag.cpp @@ -393,7 +393,7 @@ Qt::DropAction QDrag::defaultAction() const \note This is currently implemented on Windows and X11. - \since 5.6 + \since 5.7 \sa exec() */ void QDrag::cancel() diff --git a/src/gui/kernel/qplatformdrag.cpp b/src/gui/kernel/qplatformdrag.cpp index 903f6686a8..3c23406a6b 100644 --- a/src/gui/kernel/qplatformdrag.cpp +++ b/src/gui/kernel/qplatformdrag.cpp @@ -166,7 +166,7 @@ Qt::DropAction QPlatformDrag::defaultAction(Qt::DropActions possibleActions, The default implementation does nothing. - \since 5.6 + \since 5.7 */ void QPlatformDrag::cancelDrag() -- cgit v1.2.3 From 3cd1c3cb70dd57df939ad067f5668e8304d32237 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 31 Jan 2017 08:49:01 +0100 Subject: Fix libs build with msvc on Chinese locale on Windows Chinese locale means Code Page 936 here. It's also related with removing C4819 warnings. And it's also following Conventions in Qt source code: All code is ascii only (7-bit characters only, run man ascii if unsure) See also http://wiki.qt.io/Coding_Conventions Task-number: QTBUG-56155 Task-number: QTBUG-58161 Change-Id: I37fa7a0e6a82a16eaf80e1cc99be801099ab87de Reviewed-by: Friedemann Kleint Reviewed-by: jian liang Reviewed-by: Thiago Macieira --- src/3rdparty/harfbuzz/src/harfbuzz-thai.c | 2 +- src/corelib/tools/qstring.cpp | 8 ++++---- src/corelib/tools/qunicodetools.cpp | 2 +- src/plugins/generic/tuiotouch/qtuiohandler.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c index 2d4627e4f7..fe3296e887 100644 --- a/src/3rdparty/harfbuzz/src/harfbuzz-thai.c +++ b/src/3rdparty/harfbuzz/src/harfbuzz-thai.c @@ -277,7 +277,7 @@ static HB_Bool HB_ThaiConvertStringToGlyphIndices (HB_ShaperItem *item) } } - /* Special case to handle U+0E33 (SARA AM, ำ): SARA AM is normally written at the end of a + /* Special case to handle U+0E33 (SARA AM): SARA AM is normally written at the end of a * word with a base character and an optional top character before it. For example, U+0E0B * (base), U+0E49 (top), U+0E33 (SARA AM). The sequence should be converted to 4 glyphs: * base, hilo (the little circle in the top left part of SARA AM, NIKHAHIT), top, then the diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index aae4aab4c9..247119d178 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -1840,7 +1840,7 @@ QString &QString::operator=(const QString &other) Q_DECL_NOTHROW */ QString &QString::operator=(QLatin1String other) { - if (isDetached() && other.size() <= capacity()) { // assumes d->alloc == 0 → !isDetached() (sharedNull) + if (isDetached() && other.size() <= capacity()) { // assumes d->alloc == 0 -> !isDetached() (sharedNull) d->size = other.size(); d->data()[other.size()] = 0; qt_from_latin1(d->data(), other.latin1(), other.size()); @@ -1899,7 +1899,7 @@ QString &QString::operator=(QLatin1String other) */ QString &QString::operator=(QChar ch) { - if (isDetached() && capacity() >= 1) { // assumes d->alloc == 0 → !isDetached() (sharedNull) + if (isDetached() && capacity() >= 1) { // assumes d->alloc == 0 -> !isDetached() (sharedNull) // re-use existing capacity: ushort *dat = d->data(); dat[0] = ch.unicode(); @@ -8357,7 +8357,7 @@ QString &QString::setRawData(const QChar *unicode, int size) Returns the character at position \a pos in this object. \note This function performs no error checking. - The behavior is undefined when \a pos < 0 or \a pos ≥ size(). + The behavior is undefined when \a pos < 0 or \a pos >= size(). \sa operator[]() */ @@ -8368,7 +8368,7 @@ QString &QString::setRawData(const QChar *unicode, int size) Returns the character at position \a pos in this object. \note This function performs no error checking. - The behavior is undefined when \a pos < 0 or \a pos ≥ size(). + The behavior is undefined when \a pos < 0 or \a pos >= size(). \sa at() */ diff --git a/src/corelib/tools/qunicodetools.cpp b/src/corelib/tools/qunicodetools.cpp index be1d88e260..ac19d6b6d1 100644 --- a/src/corelib/tools/qunicodetools.cpp +++ b/src/corelib/tools/qunicodetools.cpp @@ -714,7 +714,7 @@ Q_CORE_EXPORT void initScripts(const ushort *string, int length, uchar *scripts) } // Never break between a combining mark (gc= Mc, Mn or Me) and its base character. - // Thus, a combining mark — whatever its script property value is — should inherit + // Thus, a combining mark - whatever its script property value is - should inherit // the script property value of its base character. static const int test = (FLAG(QChar::Mark_NonSpacing) | FLAG(QChar::Mark_SpacingCombining) | FLAG(QChar::Mark_Enclosing)); if (Q_UNLIKELY(FLAG(prop->category) & test)) diff --git a/src/plugins/generic/tuiotouch/qtuiohandler.cpp b/src/plugins/generic/tuiotouch/qtuiohandler.cpp index 26b88d6d78..eb646644ec 100644 --- a/src/plugins/generic/tuiotouch/qtuiohandler.cpp +++ b/src/plugins/generic/tuiotouch/qtuiohandler.cpp @@ -488,7 +488,7 @@ void QTuioHandler::process2DObjSet(const QOscMessage &message) return; } - qCDebug(lcTuioSet) << "Processing SET for token " << classId << id << " @ " << x << y << "∡" << angle << + qCDebug(lcTuioSet) << "Processing SET for token " << classId << id << " @ " << x << y << " angle: " << angle << "vel" << vx << vy << angularVelocity << "acc" << acceleration << angularAcceleration; QTuioToken &tok = *it; tok.setClassId(classId); -- cgit v1.2.3 From fa8edcba0d4ebb5d9f66ff951e1870beb7b6a2db Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 31 Jan 2017 21:15:24 +0100 Subject: Fix Android deployment for 64-bit targets Match the logic that is used for building. Change-Id: I9ce6db2357b9b3e19a1e932fae57d376aae406f7 Reviewed-by: Eskil Abrahamsen Blomfeldt --- mkspecs/features/android/android_deployment_settings.prf | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mkspecs/features/android/android_deployment_settings.prf b/mkspecs/features/android/android_deployment_settings.prf index 848de485f8..9fe1e26075 100644 --- a/mkspecs/features/android/android_deployment_settings.prf +++ b/mkspecs/features/android/android_deployment_settings.prf @@ -20,7 +20,10 @@ contains(TEMPLATE, ".*app"):!build_pass: { NDK_TOOLCHAIN_PREFIX = $$(ANDROID_NDK_TOOLCHAIN_PREFIX) isEmpty(NDK_TOOLCHAIN_PREFIX) { equals(ANDROID_TARGET_ARCH, x86): NDK_TOOLCHAIN_PREFIX = x86 + else: equals(ANDROID_TARGET_ARCH, x86_64): NDK_TOOLCHAIN_PREFIX = x86_64 else: equals(ANDROID_TARGET_ARCH, mips): NDK_TOOLCHAIN_PREFIX = mipsel-linux-android + else: equals(ANDROID_TARGET_ARCH, mips64): NDK_TOOLCHAIN_PREFIX = mips64el-linux-android + else: equals(ANDROID_TARGET_ARCH, arm64-v8a): NDK_TOOLCHAIN_PREFIX = aarch64-linux-android else: NDK_TOOLCHAIN_PREFIX = arm-linux-androideabi } FILE_CONTENT += " \"toolchain-prefix\": $$emitString($$NDK_TOOLCHAIN_PREFIX)," -- cgit v1.2.3 From dd2a871eaefe8925c88a835bf298180044d4b0e9 Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Tue, 10 Jan 2017 17:03:17 +0000 Subject: Clear dock indicator when not over a floating dock group window The rubberband is shown depending if there's a current hovered dock widget, but there were a few places that were not calling updateGapIndicator(). Additionally, the rubberband will also disappear if the currentHoveredFloat is destroyed externally (would leave a ghost rubber band behind). Task-number: QTBUG-58049 Change-Id: Iafdf234aa04b0ee280e51f8fa2fd212c86610cd1 Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/widgets/qmainwindowlayout.cpp | 29 +++++++++++++++++++++++++---- src/widgets/widgets/qmainwindowlayout_p.h | 3 ++- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index 72e06e4efa..68ca571acf 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -1951,6 +1951,27 @@ void QMainWindowLayout::invalidate() minSize = szHint = QSize(); } +#ifndef QT_NO_DOCKWIDGET +void QMainWindowLayout::setCurrentHoveredFloat(QWidget *w) +{ + if (currentHoveredFloat != w) { + if (currentHoveredFloat) { + disconnect(currentHoveredFloat.data(), &QObject::destroyed, + this, &QMainWindowLayout::updateGapIndicator); + } + + currentHoveredFloat = w; + + if (w) { + connect(w, &QObject::destroyed, + this, &QMainWindowLayout::updateGapIndicator, Qt::UniqueConnection); + } + + updateGapIndicator(); + } +} +#endif //QT_NO_DOCKWIDGET + /****************************************************************************** ** QMainWindowLayout - remaining stuff */ @@ -2037,7 +2058,7 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) dropTo->setParent(floatingTabs); dropTo->show(); dropTo->d_func()->plug(QRect()); - currentHoveredFloat = floatingTabs; + setCurrentHoveredFloat(floatingTabs); } #endif // QT_CONFIG(tabwidget) #if QT_CONFIG(tabbar) @@ -2190,7 +2211,7 @@ void QMainWindowLayout::animationFinished(QWidget *widget) currentGapPos.clear(); pluggingWidget = 0; #if QT_CONFIG(dockwidget) - currentHoveredFloat = nullptr; + setCurrentHoveredFloat(nullptr); #endif //applying the state will make sure that the currentGap is updated correctly //and all the geometries (especially the one from the central widget) is correct @@ -2497,12 +2518,12 @@ void QMainWindowLayout::hover(QLayoutItem *widgetItem, const QPoint &mousePos) if (!w->geometry().contains(mousePos)) continue; - currentHoveredFloat = w; + setCurrentHoveredFloat(w); restore(true); return; } } - currentHoveredFloat = Q_NULLPTR; + setCurrentHoveredFloat(nullptr); #endif //QT_NO_DOCKWIDGET QPoint pos = parentWidget()->mapFromGlobal(mousePos); diff --git a/src/widgets/widgets/qmainwindowlayout_p.h b/src/widgets/widgets/qmainwindowlayout_p.h index 857a05eb8e..ed8da61bc3 100644 --- a/src/widgets/widgets/qmainwindowlayout_p.h +++ b/src/widgets/widgets/qmainwindowlayout_p.h @@ -306,13 +306,13 @@ public: #endif #ifndef QT_NO_DOCKWIDGET QPointer currentHoveredFloat; // set when dragging over a floating dock widget + void setCurrentHoveredFloat(QWidget *w); #endif void hover(QLayoutItem *widgetItem, const QPoint &mousePos); bool plug(QLayoutItem *widgetItem); QLayoutItem *unplug(QWidget *widget, bool group = false); void revert(QLayoutItem *widgetItem); - void updateGapIndicator(); void paintDropIndicator(QPainter *p, QWidget *widget, const QRegion &clip); void applyState(QMainWindowLayoutState &newState, bool animate = true); void restore(bool keepSavedState = false); @@ -320,6 +320,7 @@ public: void animationFinished(QWidget *widget); private Q_SLOTS: + void updateGapIndicator(); #ifndef QT_NO_DOCKWIDGET #ifndef QT_NO_TABBAR void tabChanged(); -- cgit v1.2.3 From 47cded3e6f271c86de65afee00a028cbe9826403 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Sat, 29 Oct 2016 19:25:32 +0300 Subject: QSocks5SocketEngine: stop polling on UDP There is no need in additional polling, because readyRead() signal of the inner socket is directly connected to the slot which extracts the datagrams. Moreover, calling _q_udpSocketReadNotification() from the engine code might cause the spurious notifications both in the outer and inner sockets. Change-Id: Ibe75f5990e27b7460d628fa4a1ca4e64657e302c Reviewed-by: Timur Pocheptsov --- src/network/socket/qsocks5socketengine.cpp | 13 ------------- src/network/socket/qsocks5socketengine_p.h | 1 - 2 files changed, 14 deletions(-) diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index a1a8e4649d..6db09f94cf 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -1270,13 +1270,6 @@ void QSocks5SocketEnginePrivate::_q_controlSocketStateChanged(QAbstractSocket::S } #ifndef QT_NO_UDPSOCKET -void QSocks5SocketEnginePrivate::checkForDatagrams() const -{ - // udp should be unbuffered so we need to do some polling at certain points - if (udpData->udpSocket->hasPendingDatagrams()) - const_cast(this)->_q_udpSocketReadNotification(); -} - void QSocks5SocketEnginePrivate::_q_udpSocketReadNotification() { QSOCKS5_D_DEBUG << "_q_udpSocketReadNotification()"; @@ -1610,8 +1603,6 @@ bool QSocks5SocketEngine::hasPendingDatagrams() const Q_D(const QSocks5SocketEngine); Q_INIT_CHECK(false); - d->checkForDatagrams(); - return !d->udpData->pendingDatagrams.isEmpty(); } @@ -1619,8 +1610,6 @@ qint64 QSocks5SocketEngine::pendingDatagramSize() const { Q_D(const QSocks5SocketEngine); - d->checkForDatagrams(); - if (!d->udpData->pendingDatagrams.isEmpty()) return d->udpData->pendingDatagrams.head().data.size(); return 0; @@ -1632,8 +1621,6 @@ qint64 QSocks5SocketEngine::readDatagram(char *data, qint64 maxlen, QIpPacketHea #ifndef QT_NO_UDPSOCKET Q_D(QSocks5SocketEngine); - d->checkForDatagrams(); - if (d->udpData->pendingDatagrams.isEmpty()) return 0; diff --git a/src/network/socket/qsocks5socketengine_p.h b/src/network/socket/qsocks5socketengine_p.h index 864b163489..ec50d71283 100644 --- a/src/network/socket/qsocks5socketengine_p.h +++ b/src/network/socket/qsocks5socketengine_p.h @@ -248,7 +248,6 @@ public: void _q_controlSocketReadNotification(); void _q_controlSocketError(QAbstractSocket::SocketError); #ifndef QT_NO_UDPSOCKET - void checkForDatagrams() const; void _q_udpSocketReadNotification(); #endif void _q_controlSocketBytesWritten(); -- cgit v1.2.3 From 015b53e9b4091c28b8a2d7931788c2286a245201 Mon Sep 17 00:00:00 2001 From: Jian Liang Date: Mon, 30 Jan 2017 16:13:59 +0800 Subject: Turn on -utf-8 compiler option for msvc2015 update 2 and up Building qt with msvc would fail with the -developer-build configure option turned on under simplified chinese locale. This is because msvc will emit warnings for source files with utf-8 characters which are not representable in CP936, and -developer-build implies treating warnings as errors. This patch turn on -utf-8 compiler option for msvc2015 update 2 and up only for building qt. Task-number: QTBUG-58161 Change-Id: If38ea11eb1f39f8e08efa1cccb92e0eea50daf92 Reviewed-by: Oswald Buddenhagen --- mkspecs/common/msvc-version.conf | 6 ++++++ mkspecs/features/default_post.prf | 5 +++++ mkspecs/features/qt_build_config.prf | 1 + 3 files changed, 12 insertions(+) diff --git a/mkspecs/common/msvc-version.conf b/mkspecs/common/msvc-version.conf index 147009cd9f..2347ca4866 100644 --- a/mkspecs/common/msvc-version.conf +++ b/mkspecs/common/msvc-version.conf @@ -66,6 +66,12 @@ greaterThan(QMAKE_MSC_VER, 1899) { QMAKE_CFLAGS_AVX2 = -arch:AVX2 QMAKE_CXXFLAGS += -Zc:strictStrings -Zc:throwingNew QMAKE_CXXFLAGS_WARN_ON += -w44456 -w44457 -w44458 -wd4577 -wd4467 + + greaterThan(QMAKE_MSC_FULL_VER, 190023918):!intel_icl { + isEmpty(QT_CLANG_MAJOR_VERSION)|!lessThan(QT_CLANG_MAJOR_VERSION, 4) { + QMAKE_CFLAGS_UTF8_SOURCE = -utf-8 + } + } } greaterThan(QMAKE_MSC_VER, 1909) { diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf index 7f5ab3a10c..60759b445e 100644 --- a/mkspecs/features/default_post.prf +++ b/mkspecs/features/default_post.prf @@ -116,6 +116,11 @@ c++11|c++14|c++1z { unset(cxxstd) } +utf8_source { + QMAKE_CFLAGS += $$QMAKE_CFLAGS_UTF8_SOURCE + QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_UTF8_SOURCE +} + !precompile_header: SOURCES += $$NO_PCH_SOURCES QMAKE_INCDIR += $$QMAKE_INCDIR_POST diff --git a/mkspecs/features/qt_build_config.prf b/mkspecs/features/qt_build_config.prf index 3762c14f98..11d5695c63 100644 --- a/mkspecs/features/qt_build_config.prf +++ b/mkspecs/features/qt_build_config.prf @@ -84,6 +84,7 @@ android|uikit|winrt: \ CONFIG += builtin_testdata CONFIG += \ + utf8_source \ create_prl link_prl \ prepare_docs qt_docs_targets \ no_private_qt_headers_warning QTDIR_build \ -- cgit v1.2.3 From 5eb2c8c79eb7fe28e99aa0a5065ae65c13b69fed Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 18 Jan 2017 14:03:41 +0100 Subject: never use pkg-config to find opengl on darwin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit with homebrew, etc., this would find the opengl packaged with x11, which is not suitable for use with cocoa. Change-Id: I8390e1ac32c58f6644d6ef3978bdc6da9d111e79 Reviewed-by: René J.V. Bertin Reviewed-by: Jake Petroules --- src/gui/configure.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/configure.json b/src/gui/configure.json index 6f87eb5aed..35741abc86 100644 --- a/src/gui/configure.json +++ b/src/gui/configure.json @@ -181,7 +181,7 @@ "label": "Desktop OpenGL", "test": "unix/opengldesktop", "sources": [ - { "type": "pkgConfig", "args": "gl" }, + { "type": "pkgConfig", "args": "gl", "condition": "!config.darwin" }, { "type": "makeSpec", "spec": "OPENGL" } ] }, @@ -189,7 +189,7 @@ "label": "OpenGL ES 2.0", "test": "unix/opengles2", "sources": [ - { "type": "pkgConfig", "args": "glesv2" }, + { "type": "pkgConfig", "args": "glesv2", "condition": "!config.darwin" }, { "type": "makeSpec", "spec": "OPENGL_ES2" } ] }, -- cgit v1.2.3 From 1b599660219d8b54df5d075bf7aa69bfd3bf282b Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 1 Feb 2017 14:05:35 -0500 Subject: Qt5CoreMacros: append the --compiler-flavor=msvc flag Previously, the flags were replaced rather than appended to, losing -I flags and causing `#include` directives to fail. Change-Id: I74609e891ea327a8136c8075ab13176fc85ab111 Reviewed-by: Thiago Macieira --- src/corelib/Qt5CoreMacros.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake index 23909c9f3f..489bc75511 100644 --- a/src/corelib/Qt5CoreMacros.cmake +++ b/src/corelib/Qt5CoreMacros.cmake @@ -91,7 +91,7 @@ macro(QT5_GET_MOC_FLAGS _moc_flags) set(${_moc_flags} ${${_moc_flags}} -DWIN32) endif() if (MSVC) - set(${_moc_flags} --compiler-flavor=msvc) + set(${_moc_flags} ${${_moc_flags}} --compiler-flavor=msvc) endif() endmacro() -- cgit v1.2.3 From 538ef73664afda2f904b5cc0c16452cc3943cf7e Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Fri, 27 Jan 2017 14:41:21 +0100 Subject: Doc: corrected minor link issues qcore_foundation.mm: - Can't link to 'fromCGPoint()' - Undocumented parameter 'point' in QPointF::fromCGPoint() - Can't link to 'fromCGRect()' - Undocumented parameter 'rect' in QRectF::fromCGRect() - Can't link to 'fromCGSize()' - Undocumented parameter 'size' in QSizeF::fromCGSize() Change-Id: Ie48f04c7b990634f8c5a836100b1be7854848bb4 Reviewed-by: Venugopal Shivashankar --- src/corelib/kernel/qcore_foundation.mm | 12 ++++++------ src/corelib/thread/qmutex.cpp | 3 +++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/corelib/kernel/qcore_foundation.mm b/src/corelib/kernel/qcore_foundation.mm index f5ccd1c1f2..7f591a22c7 100644 --- a/src/corelib/kernel/qcore_foundation.mm +++ b/src/corelib/kernel/qcore_foundation.mm @@ -427,7 +427,7 @@ NSDate *QDateTime::toNSDate() const Creates a CGRect from a QRect. - \sa fromCGRect() + \sa QRectF::fromCGRect() */ CGRect QRect::toCGRect() const Q_DECL_NOTHROW { @@ -449,7 +449,7 @@ CGRect QRectF::toCGRect() const Q_DECL_NOTHROW /*! \since 5.8 - Creates a QRectF from a CGRect. + Creates a QRectF from CGRect \a rect. \sa toCGRect() */ @@ -465,7 +465,7 @@ QRectF QRectF::fromCGRect(CGRect rect) Q_DECL_NOTHROW Creates a CGPoint from a QPoint. - \sa fromCGPoint() + \sa QPointF::fromCGPoint() */ CGPoint QPoint::toCGPoint() const Q_DECL_NOTHROW { @@ -487,7 +487,7 @@ CGPoint QPointF::toCGPoint() const Q_DECL_NOTHROW /*! \since 5.8 - Creates a QRectF from a CGPoint. + Creates a QRectF from CGPoint \a point. \sa toCGPoint() */ @@ -503,7 +503,7 @@ QPointF QPointF::fromCGPoint(CGPoint point) Q_DECL_NOTHROW Creates a CGSize from a QSize. - \sa fromCGSize() + \sa QSizeF::fromCGSize() */ CGSize QSize::toCGSize() const Q_DECL_NOTHROW { @@ -525,7 +525,7 @@ CGSize QSizeF::toCGSize() const Q_DECL_NOTHROW /*! \since 5.8 - Creates a QRectF from a CGSize. + Creates a QRectF from \a size. \sa toCGSize() */ diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp index 653c3efe1c..b9b16e066f 100644 --- a/src/corelib/thread/qmutex.cpp +++ b/src/corelib/thread/qmutex.cpp @@ -268,6 +268,9 @@ bool QMutex::tryLock(int timeout) QT_MUTEX_LOCK_NOEXCEPT This function is provided for compatibility with the Standard Library concept \c Lockable. It is equivalent to tryLock(). + + The function returns \c true if the lock was obtained; otherwise it + returns \c false */ /*! \fn bool QMutex::try_lock_for(std::chrono::duration duration) -- cgit v1.2.3 From 71183726ae7ff87144227f6b91a32bf9ec97219c Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Fri, 10 Jun 2016 14:02:15 +0200 Subject: Win: Fixed identification of bearerType with more friendly interface name The interface name is used inside the bearer plugin to obtain additional information about the interface. Calling CreateFile with the more friendly name fails (file not found) so we use the Luid and gather information from its type. Task-number: QTBUG-51543 Change-Id: I09b7f124657a0bbccf36da6f43b36a3c50b5fde0 Reviewed-by: Timur Pocheptsov --- src/plugins/bearer/generic/generic.pro | 2 + src/plugins/bearer/generic/qgenericengine.cpp | 81 +++++++++++---------------- 2 files changed, 34 insertions(+), 49 deletions(-) diff --git a/src/plugins/bearer/generic/generic.pro b/src/plugins/bearer/generic/generic.pro index f71a901341..02b3e96bfa 100644 --- a/src/plugins/bearer/generic/generic.pro +++ b/src/plugins/bearer/generic/generic.pro @@ -12,6 +12,8 @@ SOURCES += qgenericengine.cpp \ OTHER_FILES += generic.json +win32:!winrt:LIBS += -lIphlpapi + PLUGIN_TYPE = bearer PLUGIN_CLASS_NAME = QGenericEnginePlugin load(qt_plugin) diff --git a/src/plugins/bearer/generic/qgenericengine.cpp b/src/plugins/bearer/generic/qgenericengine.cpp index 059617b367..cd3b202001 100644 --- a/src/plugins/bearer/generic/qgenericengine.cpp +++ b/src/plugins/bearer/generic/qgenericengine.cpp @@ -54,7 +54,13 @@ #include #if defined(Q_OS_WIN32) +// PMIB_TCPTABLE2 is only available since Vista +#if _WIN32_WINNT < 0x0600 +# undef _WIN32_WINNT +# define _WIN32_WINNT 0x0600 +#endif // _WIN32_WINNT < 0x0600 #include "../platformdefs_win.h" +#include #endif #ifdef Q_OS_WINRT @@ -71,9 +77,10 @@ using namespace ABI::Windows::Foundation; using namespace ABI::Windows::Foundation::Collections; using namespace ABI::Windows::Networking; using namespace ABI::Windows::Networking::Connectivity; +#endif // Q_OS_WINRT + // needed as interface is used as parameter name in qGetInterfaceType #undef interface -#endif // Q_OS_WINRT #ifdef Q_OS_LINUX #include @@ -89,62 +96,38 @@ QT_BEGIN_NAMESPACE static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interface) { #if defined(Q_OS_WIN32) - DWORD bytesWritten; - NDIS_MEDIUM medium; - NDIS_PHYSICAL_MEDIUM physicalMedium; - - unsigned long oid; - HANDLE handle = CreateFile((TCHAR *)QString::fromLatin1("\\\\.\\%1").arg(interface).utf16(), 0, - FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); - if (handle == INVALID_HANDLE_VALUE) + // QNetworkInterface::name returns a more friendly name on Windows. That name is not + // accepted as an identifier for CreateFile so we have to obtain the Luid. + std::wstring buf = interface.toStdWString(); + if (buf.size() == 0) return QNetworkConfiguration::BearerUnknown; - bytesWritten = 0; - - oid = OID_GEN_MEDIA_SUPPORTED; - bool result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid), - &medium, sizeof(medium), &bytesWritten, 0); - if (!result) { - CloseHandle(handle); + NET_LUID luid; + NETIO_STATUS status = ConvertInterfaceNameToLuidW(buf.c_str(), &luid); + if (status != NO_ERROR) return QNetworkConfiguration::BearerUnknown; - } - - bytesWritten = 0; - oid = OID_GEN_PHYSICAL_MEDIUM; - result = DeviceIoControl(handle, IOCTL_NDIS_QUERY_GLOBAL_STATS, &oid, sizeof(oid), - &physicalMedium, sizeof(physicalMedium), &bytesWritten, 0); - - if (!result) { - CloseHandle(handle); - - if (medium == NdisMedium802_3) - return QNetworkConfiguration::BearerEthernet; - else - return QNetworkConfiguration::BearerUnknown; - } - - CloseHandle(handle); - - if (medium == NdisMedium802_3) { - switch (physicalMedium) { - case NdisPhysicalMediumWirelessLan: - return QNetworkConfiguration::BearerWLAN; - case NdisPhysicalMediumBluetooth: - return QNetworkConfiguration::BearerBluetooth; - case NdisPhysicalMediumWiMax: - return QNetworkConfiguration::BearerWiMAX; - default: + switch (luid.Info.IfType) { + case IF_TYPE_ETHERNET_CSMACD: + case IF_TYPE_ISO88025_TOKENRING: + case IF_TYPE_PPP: + case IF_TYPE_SOFTWARE_LOOPBACK: + return QNetworkConfiguration::BearerEthernet; + case IF_TYPE_IEEE80211: + return QNetworkConfiguration::BearerWLAN; + case IF_TYPE_ATM: + case IF_TYPE_IEEE1394: + case IF_TYPE_OTHER: + case IF_TYPE_TUNNEL: + return QNetworkConfiguration::BearerUnknown; + default: #ifdef BEARER_MANAGEMENT_DEBUG - qDebug() << "Physical Medium" << physicalMedium; + qDebug() << "Interface Type" << luid.Info.IfType; #endif - return QNetworkConfiguration::BearerEthernet; - } + return QNetworkConfiguration::BearerUnknown; } + return QNetworkConfiguration::BearerUnknown; -#ifdef BEARER_MANAGEMENT_DEBUG - qDebug() << medium << physicalMedium; -#endif #elif defined(Q_OS_LINUX) int sock = socket(AF_INET, SOCK_DGRAM, 0); -- cgit v1.2.3 From 61371f0321e02b9835baecf4d635925aaf41e307 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 16 Jan 2017 13:07:00 +0100 Subject: tst_qurl: add test for fromUserInput(3 args) using "." as working dir As used in recent qtdeclarative commits, so better make sure it keeps working. Change-Id: I6d0ceda76201e3e7f75661cb6449e1ff32329126 Reviewed-by: Thiago Macieira --- tests/auto/corelib/io/qurl/tst_qurl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index a4461a12d3..994427ba12 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -3075,8 +3075,11 @@ void tst_QUrl::fromUserInputWithCwd_data() #endif ); // fromUserInput cleans the path } - QTest::newRow(("file-" + QByteArray::number(c++)).constData()) + QTest::newRow(("file-" + QByteArray::number(c)).constData()) << it.fileName() << QDir::currentPath() << url << url; + QTest::newRow(("file-" + QByteArray::number(c) + "-dot").constData()) + << it.fileName() << QStringLiteral(".") << url << url; + ++c; } #ifndef Q_OS_WINRT // WinRT cannot cd outside current / sandbox QDir parent = QDir::current(); -- cgit v1.2.3 From a2b4705ac66564397f78b416b8c98fe075a3bbd9 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 31 Jan 2017 11:32:01 +0100 Subject: work around mysql_config returning denormalized include paths "/usr/include/mysql/.." would slip by the removal of default include directories. so clean up the returned paths first. Task-number: QTBUG-58532 Change-Id: I445bb15619f6401494e8fffd149ea41a50ef188e Reviewed-by: Thiago Macieira --- src/sql/configure.pri | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sql/configure.pri b/src/sql/configure.pri index a8bc09e524..05794582e9 100644 --- a/src/sql/configure.pri +++ b/src/sql/configure.pri @@ -67,8 +67,11 @@ defineTest(qtConfLibrary_mysqlConfig) { libs = $$cleanlibs } $${1}.libs = "$$val_escape(libs)" - eval(includedir = $$includedir) - includedir ~= s/^-I//g + eval(rawincludedir = $$includedir) + rawincludedir ~= s/^-I//g + includedir = + for (id, rawincludedir): \ + includedir += $$clean_path($$id) includedir -= $$QMAKE_DEFAULT_INCDIRS $${1}.includedir = "$$val_escape(includedir)" export($${1}.libs) -- cgit v1.2.3 From 8286399b9e1988b18810d762c4665658bb7428f9 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 31 Jan 2017 11:19:16 +0100 Subject: fix installation of header-only frameworks in a framework build, the headers are inside the "library", so it's obviously not very wise to suppress its installation on the basis of it not being there. Task-number: QTBUG-57656 Change-Id: I026a3e486a2aad6ee0b8e0d264af4385af945e42 Reviewed-by: Jake Petroules Reviewed-by: Harald Fernengel --- mkspecs/features/qt_module.prf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/qt_module.prf b/mkspecs/features/qt_module.prf index f6cbf99c05..ec31e457db 100644 --- a/mkspecs/features/qt_module.prf +++ b/mkspecs/features/qt_module.prf @@ -68,9 +68,9 @@ load(qt_build_paths) header_module { TEMPLATE = aux - CONFIG += \ - force_qt \ # Needed for the headers_clean tests. - qt_no_install_library + CONFIG += force_qt # Needed for the headers_clean tests. + !lib_bundle: \ + CONFIG += qt_no_install_library } else { TEMPLATE = lib } -- cgit v1.2.3 From c7762f117819738a426dd091246a48befdcbef08 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 3 Feb 2017 09:19:38 +0100 Subject: Windows: Restrict synthesizing of bold to < 750 weight When a black font is used, such as Arial Black, it would cause the font to appear to be rendered twice, particularly at large point sizes. This is down to the synthesizing of the bold aspect, however since the font is actually weighted as black this is not required. Change-Id: Ie32e0da8bc67c94123631253854312ed5c25ad9f Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp b/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp index 0cd473e020..08ebbc3be0 100644 --- a/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp +++ b/src/platformsupport/fontdatabases/windows/qwindowsfontengine.cpp @@ -908,7 +908,7 @@ int QWindowsFontEngine::synthesized() const synthesized_flags = SynthesizedItalic; if (fontDef.stretch != 100 && ttf) synthesized_flags |= SynthesizedStretch; - if (tm.tmWeight >= 500 && !(macStyle & 1)) + if (tm.tmWeight >= 500 && tm.tmWeight < 750 && !(macStyle & 1)) synthesized_flags |= SynthesizedBold; //qDebug() << "font is" << _name << // "it=" << (macStyle & 2) << fontDef.style << "flags=" << synthesized_flags; -- cgit v1.2.3 From b8dbde10a065c3ba95b794b6d53ff62e8ca22ee7 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Mon, 30 Jan 2017 19:02:23 +0100 Subject: Fix data corruption when reading byte arrays from QSettings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On macOS, the code that read the plist is using QByteArray::fromRawCFData. When we return the data directly we need to detach the QByteArray so that it does not point CFData's data that will get deallocated just after the call. Task-number: QTBUG-58531 Change-Id: If829a304b986c99c8fc2aeeb992f2d539a4eef3a Reviewed-by: Thiago Macieira Reviewed-by: Tor Arne Vestbø --- src/corelib/io/qsettings_mac.cpp | 4 +++- tests/auto/corelib/io/qsettings/qsettings.qrc | 1 + tests/auto/corelib/io/qsettings/resourcefile6.plist | 10 ++++++++++ tests/auto/corelib/io/qsettings/tst_qsettings.cpp | 11 +++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 tests/auto/corelib/io/qsettings/resourcefile6.plist diff --git a/src/corelib/io/qsettings_mac.cpp b/src/corelib/io/qsettings_mac.cpp index b79abfb874..0e3520441e 100644 --- a/src/corelib/io/qsettings_mac.cpp +++ b/src/corelib/io/qsettings_mac.cpp @@ -269,8 +269,10 @@ static QVariant qtValue(CFPropertyListRef cfvalue) // Fast-path for QByteArray, so that we don't have to go // though the expensive and lossy conversion via UTF-8. - if (!byteArray.startsWith('@')) + if (!byteArray.startsWith('@')) { + byteArray.detach(); return byteArray; + } const QString str = QString::fromUtf8(byteArray.constData(), byteArray.size()); return QSettingsPrivate::stringToVariant(str); diff --git a/tests/auto/corelib/io/qsettings/qsettings.qrc b/tests/auto/corelib/io/qsettings/qsettings.qrc index c0be7e013f..c664a6f68c 100644 --- a/tests/auto/corelib/io/qsettings/qsettings.qrc +++ b/tests/auto/corelib/io/qsettings/qsettings.qrc @@ -5,6 +5,7 @@ resourcefile3.ini resourcefile4.ini resourcefile5.ini + resourcefile6.plist bom.ini diff --git a/tests/auto/corelib/io/qsettings/resourcefile6.plist b/tests/auto/corelib/io/qsettings/resourcefile6.plist new file mode 100644 index 0000000000..6f994accac --- /dev/null +++ b/tests/auto/corelib/io/qsettings/resourcefile6.plist @@ -0,0 +1,10 @@ + + + + + passwordData + + RBxVAAsDVsO/ + + + diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index f94349fd02..199ab442c4 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -178,6 +178,7 @@ private slots: void testByteArray_data(); void testByteArray(); + void testByteArrayNativeFormat(); void iniCodec(); void bom(); void embeddedZeroByte_data(); @@ -670,6 +671,16 @@ void tst_QSettings::testByteArray() } } +void tst_QSettings::testByteArrayNativeFormat() +{ +#ifndef Q_OS_MACOS + QSKIP("This test is specific to macOS plist reading."); +#else + QSettings settings(":/resourcefile6.plist", QSettings::NativeFormat); + QCOMPARE(settings.value("passwordData"), QVariant(QByteArray::fromBase64("RBxVAAsDVsO/"))); +#endif +} + void tst_QSettings::iniCodec() { { -- cgit v1.2.3 From 0e168f2c4e6f4ce3b98e86d9b140ee9fc3a9cf00 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Fri, 3 Feb 2017 14:36:42 +0300 Subject: Use nullptr in qDBusRegisterMetaType ... to make user code buildable with gcc [-Werror=zero-as-null-pointer-constant]. Change-Id: Ifef52e406c1f7d5a260612ec27922d1805aea6e2 Reviewed-by: Marc Mutz --- src/dbus/qdbusmetatype.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dbus/qdbusmetatype.h b/src/dbus/qdbusmetatype.h index 9f3d9019d7..e241553bb4 100644 --- a/src/dbus/qdbusmetatype.h +++ b/src/dbus/qdbusmetatype.h @@ -74,7 +74,7 @@ void qDBusDemarshallHelper(const QDBusArgument &arg, T *t) template int qDBusRegisterMetaType( #ifndef Q_QDOC - T * /* dummy */ = 0 + T * /* dummy */ = nullptr #endif ) { -- cgit v1.2.3 From e08f764fa7000018711b86000835f2ce7eca3fc1 Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Tue, 24 Jan 2017 11:10:39 +0100 Subject: Doc: update QtConcurrent snippets to use QRegularExpression Update the QtConcurrent code snippets to use the new QRegularExpression class in place of the deprecated QRegExp. Change-Id: I1366f902fc46bbeccc4013dd8adcf5fbfda13aed Reviewed-by: Sze Howe Koh --- .../doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp index d09c7658d4..d0deed4cc8 100644 --- a/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp +++ b/src/concurrent/doc/snippets/code/src_concurrent_qtconcurrentfilter.cpp @@ -141,12 +141,12 @@ QFuture collage = QtConcurrent::filteredReduced(images, &QImage::isGrays //! [9] -bool QString::contains(const QRegExp ®exp) const; +bool QString::contains(const QRegularExpression ®exp) const; //! [9] //! [10] -std::bind(&QString::contains, QRegExp("^\\S+$")); // matches strings without whitespace +std::bind(&QString::contains, QRegularExpression("^\\S+$")); // matches strings without whitespace //! [10] @@ -157,7 +157,7 @@ bool contains(const QString &string) //! [12] QStringList strings = ...; -std::bind(static_cast( &QString::contains ), QRegExp("..." )); +std::bind(static_cast( &QString::contains ), QRegularExpression("...")); //! [12] //! [13] -- cgit v1.2.3 From 239418a947dc5230ce295b04edc5ee5b59009c7b Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sat, 4 Feb 2017 10:52:12 -0800 Subject: Use a precise timer in tst_QTimer::remainingTime At 200 ms, the error on first firing could be 10 ms. Task-number: QTBUG-58519 Change-Id: Ifaee7464122d402991b6fffd14a02a4ce782f11f Reviewed-by: Allan Sandfeld Jensen --- tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 29ff552f6a..3c2989831e 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -158,6 +158,7 @@ void tst_QTimer::remainingTime() QTimer timer; connect(&timer, SIGNAL(timeout()), &helper, SLOT(timeout())); + timer.setTimerType(Qt::PreciseTimer); timer.start(200); QCOMPARE(helper.count, 0); -- cgit v1.2.3 From 5923fb966d3d869b23f74bc43560b08921f4321b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 1 Jun 2015 00:22:35 +0200 Subject: QDateTimeParser: de-duplicate vtable QDateTimeEdit (QtWidgets) inherits its Private class from QDateTimeParser. By making the destructor (usually the first non-inline, non-pure, virtual function, and therefore the trigger for most compilers to emit the vtable and type_info structures for the class in that TU) out-of-line, vtables and, more importantly, type_info structures for the class are pinned to a single TU. This prevents false negative dynamic_cast and catch evaluation. Since the class is already exported, users of these classes are unaffected by the change, and since it's private API, we don't need to avoid adding code to the out-of-line destructor until Qt 6. Task-number: QTBUG-45582 Change-Id: Id57289a7eff13564dddeca0af1c45a6180c36c48 Reviewed-by: Thiago Macieira --- src/corelib/tools/qdatetimeparser.cpp | 4 ++++ src/corelib/tools/qdatetimeparser_p.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qdatetimeparser.cpp b/src/corelib/tools/qdatetimeparser.cpp index 65016933a0..d66416207b 100644 --- a/src/corelib/tools/qdatetimeparser.cpp +++ b/src/corelib/tools/qdatetimeparser.cpp @@ -60,6 +60,10 @@ QT_BEGIN_NAMESPACE #ifndef QT_BOOTSTRAPPED +QDateTimeParser::~QDateTimeParser() +{ +} + /*! \internal Gets the digit from a datetime. E.g. diff --git a/src/corelib/tools/qdatetimeparser_p.h b/src/corelib/tools/qdatetimeparser_p.h index bc088a5f4c..b50c88b4c1 100644 --- a/src/corelib/tools/qdatetimeparser_p.h +++ b/src/corelib/tools/qdatetimeparser_p.h @@ -103,7 +103,7 @@ public: none.count = -1; none.zeroesAdded = 0; } - virtual ~QDateTimeParser() {} + virtual ~QDateTimeParser(); enum Section { NoSection = 0x00000, -- cgit v1.2.3 From f53ab9d7363e2fb3b63cec1a00851f84f901de18 Mon Sep 17 00:00:00 2001 From: Aleksey Lysenko Date: Mon, 30 Jan 2017 22:55:57 +0200 Subject: Reset QFileDevicePrivate::cachedSize on file close When a QFile object is reused, the atEnd() method may return incorrect values. The reason for this is that QFileDevicePrivate::cachedSize is not cleared. Setting cachedSize = 0 in the close() method fixes this issue. Task-number: QTBUG-57698 Change-Id: I828a2cf844e98d581098f2c781fa47d2cd3275ce Reviewed-by: Alex Trotsenko Reviewed-by: Oswald Buddenhagen Reviewed-by: Lars Knoll --- src/corelib/io/qfiledevice.cpp | 3 ++ tests/auto/corelib/io/qfile/tst_qfile.cpp | 62 +++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp index 20cfa5bdaf..ce9c8275ce 100644 --- a/src/corelib/io/qfiledevice.cpp +++ b/src/corelib/io/qfiledevice.cpp @@ -328,6 +328,9 @@ void QFileDevice::close() d->lastWasWrite = false; d->writeBuffer.clear(); + // reset cached size + d->cachedSize = 0; + // keep earlier error from flush if (d->fileEngine->close() && flushed) unsetError(); diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 2ef4c2c6a1..34ad2813b0 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -243,6 +243,8 @@ private slots: void invalidFile_data(); void invalidFile(); + void reuseQFile(); + private: enum FileType { OpenQFile, @@ -3436,5 +3438,65 @@ void tst_QFile::autocloseHandle() } } +void tst_QFile::reuseQFile() +{ + // QTemporaryDir is current dir, no need to remove these files + const QString filename1("filegt16k"); + const QString filename2("file16k"); + + // create test files for reusing QFile object + QFile file; + file.setFileName(filename1); + QVERIFY(file.open(QIODevice::WriteOnly)); + QByteArray ba(17408, 'a'); + qint64 written = file.write(ba); + QCOMPARE(written, 17408); + file.close(); + + file.setFileName(filename2); + QVERIFY(file.open(QIODevice::WriteOnly)); + ba.resize(16384); + written = file.write(ba); + QCOMPARE(written, 16384); + file.close(); + + QVERIFY(file.open(QIODevice::ReadOnly)); + QCOMPARE(file.size(), 16384); + QCOMPARE(file.pos(), qint64(0)); + QVERIFY(file.seek(10)); + QCOMPARE(file.pos(), qint64(10)); + QVERIFY(file.seek(0)); + QCOMPARE(file.pos(), qint64(0)); + QCOMPARE(file.readAll(), ba); + file.close(); + + file.setFileName(filename1); + QVERIFY(file.open(QIODevice::ReadOnly)); + + // read first file + { + // get file size without touching QFile + QFileInfo fi(filename1); + const qint64 fileSize = fi.size(); + file.read(fileSize); + QVERIFY(file.atEnd()); + file.close(); + } + + // try again with the next file with the same QFile object + file.setFileName(filename2); + QVERIFY(file.open(QIODevice::ReadOnly)); + + // read second file + { + // get file size without touching QFile + QFileInfo fi(filename2); + const qint64 fileSize = fi.size(); + file.read(fileSize); + QVERIFY(file.atEnd()); + file.close(); + } +} + QTEST_MAIN(tst_QFile) #include "tst_qfile.moc" -- cgit v1.2.3 From bbd091ac5853d7884929369da4e1b5d233ca504c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 5 Feb 2017 17:23:52 +0100 Subject: QGtk3Menu: fix compilation with Clang 3.8 Clang complained about a missing override: qgtk3menu.h:58:14: error: 'tag' overrides a member function but is not marked 'override' [-Werror,-Winconsistent-missing-override] Change-Id: I681cdeb93d35848ae39c1af289973b436e8ea60e Reviewed-by: Giuseppe D'Angelo --- src/plugins/platformthemes/gtk3/qgtk3menu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platformthemes/gtk3/qgtk3menu.h b/src/plugins/platformthemes/gtk3/qgtk3menu.h index ad108f1218..21e6178ec4 100644 --- a/src/plugins/platformthemes/gtk3/qgtk3menu.h +++ b/src/plugins/platformthemes/gtk3/qgtk3menu.h @@ -55,7 +55,7 @@ public: GtkWidget *create(); GtkWidget *handle() const; - quintptr tag() const; + quintptr tag() const override; void setTag(quintptr tag) override; QString text() const; -- cgit v1.2.3 From c876bb1f1333e47722e202b0916415e771137071 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 11 Jul 2016 19:55:24 +0200 Subject: QInputDialog: prevent crash in static get*() functions when parent gets deleted As explained in https://blogs.kde.org/2009/03/26/how-crash-almost-every-qtkde-application-and-how-fix-it-0 creating dialogs on the stack is a bad idea if the application or the dialog's parent window can be closed by means other than user interaction (such as a timer or an IPC call). Since we cannot know whether Qt is used to build such an application, we must assume it is, create the dialog on the heap, and monitor its lifetime with a QPointer. Instead of using manual resource management, add a minimal implementation of QAutoPointer, and use that in all static get*() functions. Task-number: QTBUG-54693 Change-Id: I6157dca18608e02be1ea2c2defbc31641defc9d1 Reviewed-by: Giuseppe D'Angelo Reviewed-by: David Faure --- src/widgets/dialogs/qdialog_p.h | 18 ++++ src/widgets/dialogs/qinputdialog.cpp | 106 ++++++++------------- .../widgets/dialogs/qinputdialog/qinputdialog.pro | 2 +- .../dialogs/qinputdialog/tst_qinputdialog.cpp | 71 ++++++++++++++ 4 files changed, 131 insertions(+), 66 deletions(-) diff --git a/src/widgets/dialogs/qdialog_p.h b/src/widgets/dialogs/qdialog_p.h index 1c7c5f3c2a..ae9e3bcc93 100644 --- a/src/widgets/dialogs/qdialog_p.h +++ b/src/widgets/dialogs/qdialog_p.h @@ -119,6 +119,24 @@ private: mutable bool m_platformHelperCreated; }; +template +class QAutoPointer { + QPointer o; + struct internal { void func() {} }; + typedef void (internal::*RestrictedBool)(); +public: + explicit QAutoPointer(T *t) Q_DECL_NOTHROW : o(t) {} + ~QAutoPointer() { delete o; } + + T *operator->() const Q_DECL_NOTHROW { return get(); } + T *get() const Q_DECL_NOTHROW { return o; } + T &operator*() const { return *get(); } + operator RestrictedBool() const Q_DECL_NOTHROW { return o ? &internal::func : Q_NULLPTR; } + bool operator!() const Q_DECL_NOTHROW { return !o; } +private: + Q_DISABLE_COPY(QAutoPointer); +}; + QT_END_NAMESPACE #endif // QDIALOG_P_H diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp index d09f77ea35..4ca3923d8d 100644 --- a/src/widgets/dialogs/qinputdialog.cpp +++ b/src/widgets/dialogs/qinputdialog.cpp @@ -1194,10 +1194,6 @@ void QInputDialog::done(int result) \snippet dialogs/standarddialogs/dialog.cpp 3 - \warning Do not delete \a parent during the execution of the dialog. If you - want to do this, you should create the dialog yourself using one of the - QInputDialog constructors. - \sa getInt(), getDouble(), getItem(), getMultiLineText() */ @@ -1205,18 +1201,18 @@ QString QInputDialog::getText(QWidget *parent, const QString &title, const QStri QLineEdit::EchoMode mode, const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) { - QInputDialog dialog(parent, flags); - dialog.setWindowTitle(title); - dialog.setLabelText(label); - dialog.setTextValue(text); - dialog.setTextEchoMode(mode); - dialog.setInputMethodHints(inputMethodHints); + QAutoPointer dialog(new QInputDialog(parent, flags)); + dialog->setWindowTitle(title); + dialog->setLabelText(label); + dialog->setTextValue(text); + dialog->setTextEchoMode(mode); + dialog->setInputMethodHints(inputMethodHints); - int ret = dialog.exec(); + const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { - return dialog.textValue(); + return dialog->textValue(); } else { return QString(); } @@ -1246,10 +1242,6 @@ QString QInputDialog::getText(QWidget *parent, const QString &title, const QStri \snippet dialogs/standarddialogs/dialog.cpp 4 - \warning Do not delete \a parent during the execution of the dialog. If you - want to do this, you should create the dialog yourself using one of the - QInputDialog constructors. - \sa getInt(), getDouble(), getItem(), getText() */ @@ -1257,18 +1249,18 @@ QString QInputDialog::getMultiLineText(QWidget *parent, const QString &title, co const QString &text, bool *ok, Qt::WindowFlags flags, Qt::InputMethodHints inputMethodHints) { - QInputDialog dialog(parent, flags); - dialog.setOptions(QInputDialog::UsePlainTextEditForTextInput); - dialog.setWindowTitle(title); - dialog.setLabelText(label); - dialog.setTextValue(text); - dialog.setInputMethodHints(inputMethodHints); + QAutoPointer dialog(new QInputDialog(parent, flags)); + dialog->setOptions(QInputDialog::UsePlainTextEditForTextInput); + dialog->setWindowTitle(title); + dialog->setLabelText(label); + dialog->setTextValue(text); + dialog->setInputMethodHints(inputMethodHints); - int ret = dialog.exec(); + const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { - return dialog.textValue(); + return dialog->textValue(); } else { return QString(); } @@ -1298,28 +1290,24 @@ QString QInputDialog::getMultiLineText(QWidget *parent, const QString &title, co \snippet dialogs/standarddialogs/dialog.cpp 0 - \warning Do not delete \a parent during the execution of the dialog. If you - want to do this, you should create the dialog yourself using one of the - QInputDialog constructors. - \sa getText(), getDouble(), getItem(), getMultiLineText() */ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &label, int value, int min, int max, int step, bool *ok, Qt::WindowFlags flags) { - QInputDialog dialog(parent, flags); - dialog.setWindowTitle(title); - dialog.setLabelText(label); - dialog.setIntRange(min, max); - dialog.setIntValue(value); - dialog.setIntStep(step); + QAutoPointer dialog(new QInputDialog(parent, flags)); + dialog->setWindowTitle(title); + dialog->setLabelText(label); + dialog->setIntRange(min, max); + dialog->setIntValue(value); + dialog->setIntStep(step); - int ret = dialog.exec(); + const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { - return dialog.intValue(); + return dialog->intValue(); } else { return value; } @@ -1350,10 +1338,6 @@ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &l \snippet dialogs/standarddialogs/dialog.cpp 0 - \warning Do not delete \a parent during the execution of the dialog. If you - want to do this, you should create the dialog yourself using one of the - QInputDialog constructors. - \sa getText(), getDouble(), getItem(), getMultiLineText() */ @@ -1379,10 +1363,6 @@ int QInputDialog::getInt(QWidget *parent, const QString &title, const QString &l \snippet dialogs/standarddialogs/dialog.cpp 1 - \warning Do not delete \a parent during the execution of the dialog. If you - want to do this, you should create the dialog yourself using one of the - QInputDialog constructors. - \sa getText(), getInt(), getItem(), getMultiLineText() */ @@ -1390,18 +1370,18 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr double value, double min, double max, int decimals, bool *ok, Qt::WindowFlags flags) { - QInputDialog dialog(parent, flags); - dialog.setWindowTitle(title); - dialog.setLabelText(label); - dialog.setDoubleDecimals(decimals); - dialog.setDoubleRange(min, max); - dialog.setDoubleValue(value); + QAutoPointer dialog(new QInputDialog(parent, flags)); + dialog->setWindowTitle(title); + dialog->setLabelText(label); + dialog->setDoubleDecimals(decimals); + dialog->setDoubleRange(min, max); + dialog->setDoubleValue(value); - int ret = dialog.exec(); + const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { - return dialog.doubleValue(); + return dialog->doubleValue(); } else { return value; } @@ -1433,10 +1413,6 @@ double QInputDialog::getDouble(QWidget *parent, const QString &title, const QStr \snippet dialogs/standarddialogs/dialog.cpp 2 - \warning Do not delete \a parent during the execution of the dialog. If you - want to do this, you should create the dialog yourself using one of the - QInputDialog constructors. - \sa getText(), getInt(), getDouble(), getMultiLineText() */ @@ -1446,19 +1422,19 @@ QString QInputDialog::getItem(QWidget *parent, const QString &title, const QStri { QString text(items.value(current)); - QInputDialog dialog(parent, flags); - dialog.setWindowTitle(title); - dialog.setLabelText(label); - dialog.setComboBoxItems(items); - dialog.setTextValue(text); - dialog.setComboBoxEditable(editable); - dialog.setInputMethodHints(inputMethodHints); + QAutoPointer dialog(new QInputDialog(parent, flags)); + dialog->setWindowTitle(title); + dialog->setLabelText(label); + dialog->setComboBoxItems(items); + dialog->setTextValue(text); + dialog->setComboBoxEditable(editable); + dialog->setInputMethodHints(inputMethodHints); - int ret = dialog.exec(); + const int ret = dialog->exec(); if (ok) *ok = !!ret; if (ret) { - return dialog.textValue(); + return dialog->textValue(); } else { return text; } diff --git a/tests/auto/widgets/dialogs/qinputdialog/qinputdialog.pro b/tests/auto/widgets/dialogs/qinputdialog/qinputdialog.pro index cc479812a8..9cb14c5350 100644 --- a/tests/auto/widgets/dialogs/qinputdialog/qinputdialog.pro +++ b/tests/auto/widgets/dialogs/qinputdialog/qinputdialog.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qinputdialog -QT += widgets testlib +QT += widgets-private testlib SOURCES += tst_qinputdialog.cpp diff --git a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp index bbb6883238..0ea9e0259f 100644 --- a/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp +++ b/tests/auto/widgets/dialogs/qinputdialog/tst_qinputdialog.cpp @@ -35,6 +35,7 @@ #include #include #include +#include class tst_QInputDialog : public QObject { @@ -52,6 +53,7 @@ private slots: void getInt(); void getDouble_data(); void getDouble(); + void taskQTBUG_54693_crashWhenParentIsDeletedWhileDialogIsOpen(); void task255502getDouble(); void getText_data(); void getText(); @@ -311,6 +313,75 @@ void tst_QInputDialog::getDouble() delete parent; } +namespace { +class SelfDestructParent : public QWidget +{ + Q_OBJECT +public: + explicit SelfDestructParent(int delay = 100) + : QWidget(Q_NULLPTR) + { + QTimer::singleShot(delay, this, SLOT(deleteLater())); + } +}; +} + +void tst_QInputDialog::taskQTBUG_54693_crashWhenParentIsDeletedWhileDialogIsOpen() +{ + // getText + { + QAutoPointer dialog(new SelfDestructParent); + bool ok = true; + const QString result = QInputDialog::getText(dialog.get(), "Title", "Label", QLineEdit::Normal, "Text", &ok); + QVERIFY(!dialog); + QVERIFY(!ok); + QVERIFY(result.isNull()); + } + + // getMultiLineText + { + QAutoPointer dialog(new SelfDestructParent); + bool ok = true; + const QString result = QInputDialog::getMultiLineText(dialog.get(), "Title", "Label", "Text", &ok); + QVERIFY(!dialog); + QVERIFY(!ok); + QVERIFY(result.isNull()); + } + + // getItem + for (int editable = false; editable <= true; ++editable) { + QAutoPointer dialog(new SelfDestructParent); + bool ok = true; + const QString result = QInputDialog::getItem(dialog.get(), "Title", "Label", + QStringList() << "1" << "2", 1, editable, &ok); + QVERIFY(!dialog); + QVERIFY(!ok); + QCOMPARE(result, QLatin1String("2")); + } + + // getInt + { + const int initial = 7; + QAutoPointer dialog(new SelfDestructParent); + bool ok = true; + const int result = QInputDialog::getInt(dialog.get(), "Title", "Label", initial, -10, +10, 1, &ok); + QVERIFY(!dialog); + QVERIFY(!ok); + QCOMPARE(result, initial); + } + + // getDouble + { + const double initial = 7; + QAutoPointer dialog(new SelfDestructParent); + bool ok = true; + const double result = QInputDialog::getDouble(dialog.get(), "Title", "Label", initial, -10, +10, 2, &ok); + QVERIFY(!dialog); + QVERIFY(!ok); + QCOMPARE(result, initial); + } +} + void tst_QInputDialog::task255502getDouble() { parent = new QWidget; -- cgit v1.2.3 From e1c93cc74b43d8c49208b38dde824298590ac788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Fri, 13 Jan 2017 17:17:14 +0100 Subject: QDBusTrayIcon: try use runtime or cache for icons It's better to save icons in $XDG_RUNTIME_DIR or $XDG_CACHE_HOME paths than in $TMPDIR as these places are readable from the desktop environment when an app is ran confined in a sandbox (as in snap packages) Change-Id: I1a3e4c5714f8ea51034d18fb87cead87ed21d6be Reviewed-by: Shawn Rutledge Reviewed-by: Dmitry Shachnev --- .../themes/genericunix/dbustray/qdbustrayicon.cpp | 25 +++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp index b55ace357a..9baf94726d 100644 --- a/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp +++ b/src/platformsupport/themes/genericunix/dbustray/qdbustrayicon.cpp @@ -65,9 +65,32 @@ QT_BEGIN_NAMESPACE Q_LOGGING_CATEGORY(qLcTray, "qt.qpa.tray") +static QString iconTempPath() +{ + QString tempPath = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); + if (!tempPath.isEmpty()) + return tempPath; + + tempPath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation); + + if (!tempPath.isEmpty()) { + QDir tempDir(tempPath); + if (tempDir.exists()) + return tempPath; + + if (tempDir.mkpath(QStringLiteral("."))) { + const QFile::Permissions permissions = QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner; + if (QFile(tempPath).setPermissions(permissions)) + return tempPath; + } + } + + return QDir::tempPath(); +} + static const QString KDEItemFormat = QStringLiteral("org.kde.StatusNotifierItem-%1-%2"); static const QString KDEWatcherService = QStringLiteral("org.kde.StatusNotifierWatcher"); -static const QString TempFileTemplate = QDir::tempPath() + QLatin1String("/qt-trayicon-XXXXXX.png"); +static const QString TempFileTemplate = iconTempPath() + QLatin1String("/qt-trayicon-XXXXXX.png"); static const QString XdgNotificationService = QStringLiteral("org.freedesktop.Notifications"); static const QString XdgNotificationPath = QStringLiteral("/org/freedesktop/Notifications"); static const QString DefaultAction = QStringLiteral("default"); -- cgit v1.2.3 From ad51c8aa0a00c1bbec7386472ca454079e284051 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 19 Jan 2017 21:54:41 +0100 Subject: make more use of configure QMAKE_*= arguments in native builds don't ignore the variable assignments for host tools when we're not actually cross-building. (sort of) amends 5060740f. Task-number: QTBUG-58511 Change-Id: Ideda25fb18a4e0b2d54179b08b6301b94a48e51c Reviewed-by: Joerg Bornemann --- configure.pri | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.pri b/configure.pri index b7dd9d460f..d49f5f8db2 100644 --- a/configure.pri +++ b/configure.pri @@ -997,7 +997,7 @@ defineTest(qtConfOutput_gccSysroot) { defineTest(qtConfOutput_qmakeArgs) { !$${2}: return() - $${currentConfig}.output.privatePro = "!host_build {" + $${currentConfig}.output.privatePro = "!host_build|!cross_compile {" for (a, config.input.qmakeArgs) { $${currentConfig}.output.privatePro += " $$a" EXTRA_QMAKE_ARGS += $$system_quote($$a) -- cgit v1.2.3 From 4adc1012e19f5e12ab2fb96effc9ea88d2a05eda Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 3 Feb 2017 18:12:52 +0100 Subject: add a bunch of complementary options to -after in particular, -before (just for symmetry, as it's the default), -early (the actual objective), and -late (for symmetry again). Change-Id: I274303582a348b052c3e5106ff360ab4fd7d4ee2 Reviewed-by: Joerg Bornemann --- qmake/generators/projectgenerator.cpp | 8 ++++---- qmake/generators/win32/msvc_vcproj.cpp | 6 +++--- qmake/library/qmakeevaluator.cpp | 12 +++++++++--- qmake/library/qmakeglobals.cpp | 33 ++++++++++++++++----------------- qmake/library/qmakeglobals.h | 13 ++++++++----- qmake/option.cpp | 14 ++++++++++---- 6 files changed, 50 insertions(+), 36 deletions(-) diff --git a/qmake/generators/projectgenerator.cpp b/qmake/generators/projectgenerator.cpp index e45217cb45..3f6af8fc08 100644 --- a/qmake/generators/projectgenerator.cpp +++ b/qmake/generators/projectgenerator.cpp @@ -326,8 +326,8 @@ ProjectGenerator::writeMakefile(QTextStream &t) t << "######################################################################" << endl; t << "# Automatically generated by qmake (" QMAKE_VERSION_STR ") " << QDateTime::currentDateTime().toString() << endl; t << "######################################################################" << endl << endl; - if (!Option::globals->precmds.isEmpty()) - t << Option::globals->precmds << endl; + if (!Option::globals->extra_cmds[QMakeEvalBefore].isEmpty()) + t << Option::globals->extra_cmds[QMakeEvalBefore] << endl; t << getWritableVar("TEMPLATE_ASSIGN", false); if(project->first("TEMPLATE_ASSIGN") == "subdirs") { t << endl << "# Directories" << "\n" @@ -353,8 +353,8 @@ ProjectGenerator::writeMakefile(QTextStream &t) << getWritableVar("RESOURCES") << getWritableVar("TRANSLATIONS"); } - if (!Option::globals->postcmds.isEmpty()) - t << Option::globals->postcmds << endl; + if (!Option::globals->extra_cmds[QMakeEvalAfter].isEmpty()) + t << Option::globals->extra_cmds[QMakeEvalAfter] << endl; return true; } diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index ef4e9f29b6..a7312d0124 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -664,8 +664,8 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) // Make sure that all temp projects are configured // for release so that the depends are created // without the debug dxxx.lib name mangling - QString old_after_vars = Option::globals->postcmds; - Option::globals->postcmds.append("\nCONFIG+=release"); + QString old_after_vars = Option::globals->extra_cmds[QMakeEvalAfter]; + Option::globals->extra_cmds[QMakeEvalAfter].append("\nCONFIG+=release"); QHash profileLookup; QHash projGuids; @@ -719,7 +719,7 @@ void VcprojGenerator::writeSubDirs(QTextStream &t) t << slnConf; // Restore previous after_user_var options - Option::globals->postcmds = old_after_vars; + Option::globals->extra_cmds[QMakeEvalAfter] = old_after_vars; t << _slnProjConfBeg; for(QList::Iterator it = solution_cleanup.begin(); it != solution_cleanup.end(); ++it) { diff --git a/qmake/library/qmakeevaluator.cpp b/qmake/library/qmakeevaluator.cpp index 38c0cec23f..a5fa0d22a6 100644 --- a/qmake/library/qmakeevaluator.cpp +++ b/qmake/library/qmakeevaluator.cpp @@ -1443,6 +1443,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile( if (flags & LoadPreFiles) { setupProject(); + if (!m_option->extra_cmds[QMakeEvalEarly].isEmpty()) + evaluateCommand(m_option->extra_cmds[QMakeEvalEarly], fL1S("(command line -early)")); + for (ProValueMap::ConstIterator it = m_extraVars.constBegin(); it != m_extraVars.constEnd(); ++it) m_valuemapStack.first().insert(it.key(), it.value()); @@ -1454,8 +1457,8 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile( if ((vr = evaluateFeatureFile(QLatin1String("default_pre.prf"))) == ReturnError) goto failed; - if (!m_option->precmds.isEmpty()) { - evaluateCommand(m_option->precmds, fL1S("(command line)")); + if (!m_option->extra_cmds[QMakeEvalBefore].isEmpty()) { + evaluateCommand(m_option->extra_cmds[QMakeEvalBefore], fL1S("(command line)")); // Again, after user configs, to override them applyExtraConfigs(); @@ -1468,7 +1471,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile( debugMsg(1, "done visiting file %s", qPrintable(pro->fileName())); if (flags & LoadPostFiles) { - evaluateCommand(m_option->postcmds, fL1S("(command line -after)")); + evaluateCommand(m_option->extra_cmds[QMakeEvalAfter], fL1S("(command line -after)")); // Again, to ensure the project does not mess with us. // Specifically, do not allow a project to override debug/release within a @@ -1478,6 +1481,9 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProFile( if ((vr = evaluateFeatureFile(QLatin1String("default_post.prf"))) == ReturnError) goto failed; + if (!m_option->extra_cmds[QMakeEvalLate].isEmpty()) + evaluateCommand(m_option->extra_cmds[QMakeEvalLate], fL1S("(command line -late)")); + if ((vr = evaluateConfigFeatures()) == ReturnError) goto failed; } diff --git a/qmake/library/qmakeglobals.cpp b/qmake/library/qmakeglobals.cpp index b282b08d5c..b6dc8b20b6 100644 --- a/qmake/library/qmakeglobals.cpp +++ b/qmake/library/qmakeglobals.cpp @@ -111,10 +111,7 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments( QString arg = args.at(*pos); switch (argState) { case ArgConfig: - if (state.after) - state.postconfigs << arg; - else - state.preconfigs << arg; + state.configs[state.phase] << arg; break; case ArgSpec: qmakespec = args[*pos] = cleanSpec(state, arg); @@ -141,8 +138,14 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments( args.erase(args.begin() + *pos, args.end()); return ArgumentsOk; } - if (arg == QLatin1String("-after")) - state.after = true; + if (arg == QLatin1String("-early")) + state.phase = QMakeEvalEarly; + else if (arg == QLatin1String("-before")) + state.phase = QMakeEvalBefore; + else if (arg == QLatin1String("-after")) + state.phase = QMakeEvalAfter; + else if (arg == QLatin1String("-late")) + state.phase = QMakeEvalLate; else if (arg == QLatin1String("-config")) argState = ArgConfig; else if (arg == QLatin1String("-nocache")) @@ -166,10 +169,7 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments( else return ArgumentUnknown; } else if (arg.contains(QLatin1Char('='))) { - if (state.after) - state.postcmds << arg; - else - state.precmds << arg; + state.cmds[state.phase] << arg; } else { return ArgumentUnknown; } @@ -184,18 +184,17 @@ QMakeGlobals::ArgumentReturn QMakeGlobals::addCommandLineArguments( void QMakeGlobals::commitCommandLineArguments(QMakeCmdLineParserState &state) { - if (!state.preconfigs.isEmpty()) - state.precmds << (fL1S("CONFIG += ") + state.preconfigs.join(QLatin1Char(' '))); if (!state.extraargs.isEmpty()) { QString extra = fL1S("QMAKE_EXTRA_ARGS ="); for (const QString &ea : qAsConst(state.extraargs)) extra += QLatin1Char(' ') + QMakeEvaluator::quoteValue(ProString(ea)); - state.precmds << extra; + state.cmds[QMakeEvalBefore] << extra; + } + for (int p = 0; p < 4; p++) { + if (!state.configs[p].isEmpty()) + state.cmds[p] << (fL1S("CONFIG += ") + state.configs[p].join(QLatin1Char(' '))); + extra_cmds[p] = state.cmds[p].join(QLatin1Char('\n')); } - precmds = state.precmds.join(QLatin1Char('\n')); - if (!state.postconfigs.isEmpty()) - state.postcmds << (fL1S("CONFIG += ") + state.postconfigs.join(QLatin1Char(' '))); - postcmds = state.postcmds.join(QLatin1Char('\n')); if (xqmakespec.isEmpty()) xqmakespec = qmakespec; diff --git a/qmake/library/qmakeglobals.h b/qmake/library/qmakeglobals.h index 86b1d28da4..000f685b73 100644 --- a/qmake/library/qmakeglobals.h +++ b/qmake/library/qmakeglobals.h @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE class QMakeEvaluator; +enum QMakeEvalPhase { QMakeEvalEarly, QMakeEvalBefore, QMakeEvalAfter, QMakeEvalLate }; + class QMakeBaseKey { public: @@ -83,12 +85,13 @@ public: class QMAKE_EXPORT QMakeCmdLineParserState { public: - QMakeCmdLineParserState(const QString &_pwd) : pwd(_pwd), after(false) {} + QMakeCmdLineParserState(const QString &_pwd) : pwd(_pwd), phase(QMakeEvalBefore) {} QString pwd; - QStringList precmds, preconfigs, postcmds, postconfigs, extraargs; - bool after; + QStringList cmds[4], configs[4]; + QStringList extraargs; + QMakeEvalPhase phase; - void flush() { after = false; } + void flush() { phase = QMakeEvalBefore; } }; class QMAKE_EXPORT QMakeGlobals @@ -110,7 +113,7 @@ public: QString qtconf; QString qmakespec, xqmakespec; QString user_template, user_template_prefix; - QString precmds, postcmds; + QString extra_cmds[4]; #ifdef PROEVALUATOR_DEBUG int debugLevel; diff --git a/qmake/option.cpp b/qmake/option.cpp index 9dcd343c8a..52f9cb8a0e 100644 --- a/qmake/option.cpp +++ b/qmake/option.cpp @@ -151,17 +151,23 @@ bool usage(const char *a0) " -Wdeprecated Turn on deprecation warnings (on by default)\n" "\n" "Options:\n" - " * You can place any variable assignment in options and it will be *\n" - " * processed as if it was in [files]. These assignments will be parsed *\n" - " * before [files]. *\n" + " * You can place any variable assignment in options and it will be *\n" + " * processed as if it was in [files]. These assignments will be *\n" + " * processed before [files] by default. *\n" " -o file Write output to file\n" " -d Increase debug level\n" " -t templ Overrides TEMPLATE as templ\n" " -tp prefix Overrides TEMPLATE so that prefix is prefixed into the value\n" " -help This help\n" " -v Version information\n" - " -after All variable assignments after this will be\n" + " -early All subsequent variable assignments will be\n" + " parsed right before default_pre.prf\n" + " -before All subsequent variable assignments will be\n" + " parsed right before [files] (the default)\n" + " -after All subsequent variable assignments will be\n" " parsed after [files]\n" + " -late All subsequent variable assignments will be\n" + " parsed right after default_post.prf\n" " -norecursive Don't do a recursive search\n" " -recursive Do a recursive search\n" " -set Set persistent property\n" -- cgit v1.2.3 From 2982d327f7c51f448e91e12da29179d980027931 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 3 Feb 2017 18:23:04 +0100 Subject: adjust configure to native build optimizations don't fail to set up cross_compile early enough. otherwise, we'd populate the cache for target builds with data for the host. amends 6b8666c7 and 5060740f. conversely, pass on extra flags to configure tests when not cross building. amends d8be8110 (and 2c5eb3e6). Task-number: QTBUG-58556 Change-Id: I531d71e06204a0b17ae6dabf017a52e0f2efd9a7 Reviewed-by: Joerg Bornemann --- configure.json | 2 +- configure.pri | 11 +++++++++++ mkspecs/features/qt_configure.prf | 8 +++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/configure.json b/configure.json index e9ffc972ab..9a9645a23a 100644 --- a/configure.json +++ b/configure.json @@ -454,7 +454,7 @@ "cross_compile": { "label": "Cross compiling", "condition": "call.crossCompile", - "output": [ "publicConfig", "privateConfig" ] + "output": [ "publicConfig", "privateConfig", "crossCompile" ] }, "cxx11default": { "label": "Compiler defaults to C++11 or higher", diff --git a/configure.pri b/configure.pri index d49f5f8db2..74eef36667 100644 --- a/configure.pri +++ b/configure.pri @@ -830,6 +830,9 @@ defineTest(qtConfOutput_reloadSpec) { !isEmpty(config.input.sysroot): \ reloadSpec() + # toolchain.prf uses this. + dummy = $$qtConfEvaluate("features.cross_compile") + bypassNesting() { QMAKE_INTERNAL_INCLUDED_FEATURES -= \ $$[QT_HOST_DATA/src]/mkspecs/features/mac/toolchain.prf \ @@ -913,6 +916,14 @@ defineTest(qtConfOutput_pkgConfig) { } } +defineTest(qtConfOutput_crossCompile) { + !$${2}: return() + + # We need to preempt the output here, as subsequent tests rely on it + CONFIG += cross_compile + export(CONFIG) +} + defineTest(qtConfOutput_useGoldLinker) { !$${2}: return() diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 1f7fb1b292..81c63205a7 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -746,7 +746,7 @@ defineTest(qtConfTest_compile) { qmake_args += "\"CONFIG += $$qmake_configs\"" - !$$host { + !$$host|!cross_compile { # On WinRT we need to change the entry point as we cannot create windows # applications winrt: \ @@ -764,6 +764,12 @@ defineTest(qtConfTest_compile) { qmake_args += $$EXTRA_QMAKE_ARGS } + # make sure to make this the last override (because of -early) + cross_compile { + # must be done before loading default_pre.prf. + qmake_args += -early "\"CONFIG += cross_compile\"" + } + # Clean up after previous run exists($$test_out_dir/Makefile): \ QMAKE_MAKE = "$$QMAKE_MAKE clean && $$QMAKE_MAKE" -- cgit v1.2.3 From dbc3d8e15e7a158b540370d9f864fafdb55eddb4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 6 Jan 2016 10:01:07 +0100 Subject: Unbreak ubsan developer-build Clang 3.8's undefined-behavior sanitizer checks that the declared type of the object is a base class of the dynamic type of the object on each access to a member of a class type. It therefore requires the typeinfo for these types, which for polymorphic types is emitted in the TU where the vtable is emitted, too. QDBusConnectionPrivate is a polymorphic non-exported class, so this failed at link-time. Ditto for the other case. Fix by autotest-exporting the classes. Also, where applicable, de-inline the dtors, so the vtable (and typeinfo) are pinned to one TU, and the ctor, just because it's the correct thing to do. Change-Id: I991f81f88d2a48e85d94d9f3ac61473c0b7056d3 Reviewed-by: Thiago Macieira --- src/dbus/qdbusconnection_p.h | 2 +- src/sql/models/qsqltablemodel.cpp | 5 +++++ src/sql/models/qsqltablemodel_p.h | 4 +++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/dbus/qdbusconnection_p.h b/src/dbus/qdbusconnection_p.h index a63e976f99..875bcd1421 100644 --- a/src/dbus/qdbusconnection_p.h +++ b/src/dbus/qdbusconnection_p.h @@ -107,7 +107,7 @@ public: // QDBusConnectionPrivate holds the DBusConnection and // can have many QDBusConnection objects referring to it -class QDBusConnectionPrivate: public QObject +class Q_AUTOTEST_EXPORT QDBusConnectionPrivate: public QObject { Q_OBJECT public: diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 9932fb75e3..8166613e53 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -55,6 +55,11 @@ QT_BEGIN_NAMESPACE typedef QSqlTableModelSql Sql; +QSqlTableModelPrivate::~QSqlTableModelPrivate() +{ + +} + /*! \internal Populates our record with values. */ diff --git a/src/sql/models/qsqltablemodel_p.h b/src/sql/models/qsqltablemodel_p.h index 4a79d5db36..3b64cdfa47 100644 --- a/src/sql/models/qsqltablemodel_p.h +++ b/src/sql/models/qsqltablemodel_p.h @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE -class QSqlTableModelPrivate: public QSqlQueryModelPrivate +class Q_AUTOTEST_EXPORT QSqlTableModelPrivate: public QSqlQueryModelPrivate { Q_DECLARE_PUBLIC(QSqlTableModel) @@ -69,6 +69,8 @@ public: strategy(QSqlTableModel::OnRowChange), busyInsertingRows(false) {} + ~QSqlTableModelPrivate(); + void clear(); virtual void clearCache(); QSqlRecord record(const QVector &values) const; -- cgit v1.2.3 From 2294d1fb1a778b13d2514e7bb92e80b9cc4c6356 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Mon, 30 Jan 2017 13:56:32 +0100 Subject: Doc: Ignore QML/JavaScript parsing errors QDoc reports warnings for every QML code snippet that's not a complete QML type declaration - ignore these warnings because in majority of the cases, they're not indicative of any actual problems in the code. Change-Id: I53d13e2ae683ca8c5473f68eda17c61199de1ff8 Reviewed-by: Venugopal Shivashankar --- doc/global/compat.qdocconf | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/global/compat.qdocconf b/doc/global/compat.qdocconf index 12d061a28a..df3f49c653 100644 --- a/doc/global/compat.qdocconf +++ b/doc/global/compat.qdocconf @@ -6,4 +6,5 @@ macro.endquote = "\\endquotation" macro.relatesto = "\\relates" spurious = "Missing comma in .*" \ - "Missing pattern .*" + "Missing pattern .*" \ + "Unable to parse (QML|JavaScript).*" -- cgit v1.2.3 From d0b8356e7efcb546bf8838b01b94840e4c0d3ab3 Mon Sep 17 00:00:00 2001 From: Vyacheslav Koscheev Date: Thu, 26 Jan 2017 14:07:48 +0700 Subject: Android: Fix data race in QAndroidEventDispatcherStopper Change-Id: If5f8406d7af2d91e267a0ba380e73287feabac9f Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/qandroideventdispatcher.cpp | 6 ++---- src/plugins/platforms/android/qandroideventdispatcher.h | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/plugins/platforms/android/qandroideventdispatcher.cpp b/src/plugins/platforms/android/qandroideventdispatcher.cpp index 104e905b8f..e12551283f 100644 --- a/src/plugins/platforms/android/qandroideventdispatcher.cpp +++ b/src/plugins/platforms/android/qandroideventdispatcher.cpp @@ -108,10 +108,9 @@ QAndroidEventDispatcherStopper *QAndroidEventDispatcherStopper::instance() void QAndroidEventDispatcherStopper::startAll() { QMutexLocker lock(&m_mutex); - if (started) + if (!m_started.testAndSetOrdered(0, 1)) return; - started = true; for (QAndroidEventDispatcher *d : qAsConst(m_dispatchers)) d->start(); } @@ -119,10 +118,9 @@ void QAndroidEventDispatcherStopper::startAll() void QAndroidEventDispatcherStopper::stopAll() { QMutexLocker lock(&m_mutex); - if (!started) + if (!m_started.testAndSetOrdered(1, 0)) return; - started = false; for (QAndroidEventDispatcher *d : qAsConst(m_dispatchers)) d->stop(); } diff --git a/src/plugins/platforms/android/qandroideventdispatcher.h b/src/plugins/platforms/android/qandroideventdispatcher.h index 057a1660c9..e6f903bced 100644 --- a/src/plugins/platforms/android/qandroideventdispatcher.h +++ b/src/plugins/platforms/android/qandroideventdispatcher.h @@ -68,7 +68,7 @@ class QAndroidEventDispatcherStopper { public: static QAndroidEventDispatcherStopper *instance(); - static bool stopped() {return !instance()->started; } + static bool stopped() {return !instance()->m_started.load(); } void startAll(); void stopAll(); void addEventDispatcher(QAndroidEventDispatcher *dispatcher); @@ -77,7 +77,7 @@ public: private: QMutex m_mutex; - bool started = true; + QAtomicInt m_started = 1; QVector m_dispatchers; }; -- cgit v1.2.3 From 8b1d9d308b1f31e1b9c817e0d91e14baa3b76d6b Mon Sep 17 00:00:00 2001 From: Samuel Gaist Date: Mon, 29 Aug 2016 09:59:46 +0200 Subject: Fix result handling in QDialog::done The setData method of an item view would get an incorrect value of a QDialog's result. This patch changes the order of functions called to fix that. [ChangeLog][QtWidgets][QDialog] Fixed a bug where accessing the result of QDialog's result could yield an incorrect value in some situation like using it as a delegate for item views. Task-number: QTBUG-6018 Task-number: QTBUG-12156 Task-number: QTBUG-14430 Change-Id: I6ee4b6e8cacf6a806631c05c6c5dbcff925df65e Reviewed-by: Shawn Rutledge Reviewed-by: Jesus Fernandez Reviewed-by: Timur Pocheptsov --- src/widgets/dialogs/qdialog.cpp | 2 +- .../qabstractitemview/tst_qabstractitemview.cpp | 57 ++++++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index e8883df527..e5715ecd57 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -557,8 +557,8 @@ int QDialog::exec() void QDialog::done(int r) { Q_D(QDialog); - hide(); setResult(r); + hide(); d->close_helper(QWidgetPrivate::CloseNoEvent); d->resetModalitySetByOpen(); diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index 426db265ae..d241296a6b 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -52,6 +52,7 @@ #include #include #include +#include static inline void setFrameless(QWidget *w) { @@ -149,6 +150,7 @@ private slots: void QTBUG50535_update_on_new_selection_model(); void testSelectionModelInSyncWithView(); void testClickToSelect(); + void testDialogAsEditor(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -173,6 +175,29 @@ public: QSize size; }; +class DialogItemDelegate : public QStyledItemDelegate +{ +public: + DialogItemDelegate() : QStyledItemDelegate() { } + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &, const QModelIndex &) const + { + openedEditor = new QDialog(parent); + return openedEditor; + } + + void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const + { + Q_UNUSED(model) + Q_UNUSED(index) + + QDialog *dialog = qobject_cast(editor); + result = static_cast(dialog->result()); + } + + mutable QDialog::DialogCode result; + mutable QDialog *openedEditor; +}; + // Testing get/set functions void tst_QAbstractItemView::getSetCheck() { @@ -2156,5 +2181,37 @@ void tst_QAbstractItemView::testClickToSelect() QCOMPARE(spy.back().front().value(), QRect(nearCenterA, QSize(1, 1))); } +void tst_QAbstractItemView::testDialogAsEditor() +{ + DialogItemDelegate delegate; + + QStandardItemModel model; + model.appendRow(new QStandardItem(QStringLiteral("editme"))); + + QListView view; + view.setItemDelegate(&delegate); + view.setModel(&model); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + view.edit(model.index(0,0)); + + QVERIFY(QTest::qWaitForWindowExposed(delegate.openedEditor)); + + delegate.openedEditor->reject(); + QApplication::processEvents(); + + QCOMPARE(delegate.result, QDialog::Rejected); + + view.edit(model.index(0,0)); + + QVERIFY(QTest::qWaitForWindowExposed(delegate.openedEditor)); + + delegate.openedEditor->accept(); + QApplication::processEvents(); + + QCOMPARE(delegate.result, QDialog::Accepted); +} + QTEST_MAIN(tst_QAbstractItemView) #include "tst_qabstractitemview.moc" -- cgit v1.2.3 From e7034fddfe1e3875e01abd268588738a7f6672ad Mon Sep 17 00:00:00 2001 From: Nico Vertriest Date: Fri, 27 Jan 2017 15:57:37 +0100 Subject: Doc: link issue and qdoc error on parameter - No such parameter 'image' in QImage::toCGImage() - Can't link to 'toNSImage() Change-Id: Ida559fb1211d1e196d9a9a50d97566124e82eb2f Reviewed-by: Venugopal Shivashankar --- src/gui/image/qimage_darwin.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qimage_darwin.mm b/src/gui/image/qimage_darwin.mm index d72733abd3..2d38468cc5 100644 --- a/src/gui/image/qimage_darwin.mm +++ b/src/gui/image/qimage_darwin.mm @@ -41,7 +41,7 @@ QT_BEGIN_NAMESPACE /*! - Creates a \c CGImage equivalent to the QImage \a image. Returns a + Creates a \c CGImage equivalent to this QImage. Returns a \c CGImageRef handle. The returned CGImageRef partakes in the QImage implicit sharing, @@ -85,7 +85,7 @@ QT_BEGIN_NAMESPACE The CGImageRef color space is set to the sRGB color space. - \sa toNSImage() + \sa QtMac::toNSImage() */ CGImageRef QImage::toCGImage() const { -- cgit v1.2.3 From c7e49651f1945e6fb9dd7a4e74ff3c89259396f6 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Sun, 5 Feb 2017 11:26:41 +0100 Subject: Use categorized logging in qaccessible.cpp Change-Id: I244a1ef8bae2cc0392dae4ef8f3fbb47630e1d56 Reviewed-by: Marc Mutz --- src/gui/accessible/qaccessible.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 874b99be4f..5ed724047f 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -52,12 +52,15 @@ #include #include +#include #include #include #include QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcAccessibilityCore, "qt.accessibility.core"); + /*! \class QAccessible \brief The QAccessible class provides enums and static functions @@ -1769,7 +1772,7 @@ QAccessibleInterface *QAccessibleEvent::accessibleInterface() const if (child) { iface = child; } else { - qWarning() << "Cannot creat accessible child interface for object: " << m_object << " index: " << m_child; + qCWarning(lcAccessibilityCore) << "Cannot create accessible child interface for object: " << m_object << " index: " << m_child; } } return iface; -- cgit v1.2.3 From e9686b3718c396333c368e14cda48f407276c106 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Sat, 4 Feb 2017 13:24:15 +0100 Subject: Protect against nullptr deref in QAccessibleEvent::uniqueId MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This looks like an underlying issue in the model/view implementation which relies on accessible interfaces that are not representing a qobject. We know it's not perfect and needs fixing, but for now at least don't crash. [ChangeLog][macOS][Accessibility] A common crash in accessibility on macOS was fixed. See QTBUG-39008 Task-number: QTBUG-39008 Task-number: QTBUG-54776 Task-number: QTBUG-56043 Task-number: QTBUG-57146 Change-Id: I16b161914d4bc3cbc0beee37d468243bf7788d1e Reviewed-by: Marc Mutz Reviewed-by: Jan Arve Sæther --- src/gui/accessible/qaccessible.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index 5ed724047f..2db4d46874 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -1373,8 +1373,13 @@ QAccessible::Id QAccessibleEvent::uniqueId() const QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(m_object); if (!iface) return 0; - if (m_child != -1) + if (m_child != -1) { iface = iface->child(m_child); + if (Q_UNLIKELY(!iface)) { + qCWarning(lcAccessibilityCore) << "Invalid child in QAccessibleEvent:" << m_object << "child:" << m_child; + return 0; + } + } return QAccessible::uniqueId(iface); } -- cgit v1.2.3 From ee348975654bb5f659370118dcf7b4bb494add87 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Sun, 5 Feb 2017 10:48:44 +0100 Subject: Fix regression preventing VoiceOver following the keyboard focus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In fafdb171e0c317ee8f871dc7b504d3713d5860eb a potential nullptr deref was fixed, but it changed the hierarchy of accessible objects. The new hierarchy would prefer to send a parent object that represents the application, but macOS needs the window to be in the hierarchy for VoiceOver to behave as expected. Tweak it so that we give the window as parent again, not the app. Change-Id: I5f7f59b07d0966c8bcf96968e4ed65eba9e05be6 Reviewed-by: Jan Arve Sæther --- src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index e743dd56bf..6001a845e8 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -235,9 +235,16 @@ static void convertLineOffset(QAccessibleTextInterface *text, int *line, int *of if (!iface || !iface->isValid()) return nil; + // macOS expects that the hierarchy is: + // App -> Window -> Children + // We don't actually have the window reflected properly in QAccessibility. + // Check if the parent is the application and then instead return the native window. + if (QAccessibleInterface *parent = iface->parent()) { - QAccessible::Id parentId = QAccessible::uniqueId(parent); - return [QMacAccessibilityElement elementWithId: parentId]; + if (parent->role() != QAccessible::Application) { + QAccessible::Id parentId = QAccessible::uniqueId(parent); + return [QMacAccessibilityElement elementWithId: parentId]; + } } if (QWindow *window = iface->window()) { -- cgit v1.2.3 From 18e6e8105971df910ab3881ee36476432d17e382 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 7 Feb 2017 10:44:55 +0100 Subject: QCollator/ICU: fix a rather hair-raising performance bug in compare(QChar*, int, QChar*, int) The intention when using an overload that takes (const QChar*, int) instead of a QString is probably to avoid creating a QString in the first place. If the implementation stabbs the user in the back by internally creating a QString just so it can call QString::compare() on it, then that is rather unacceptable. QCollator is already a friend of QString, so, absent QStringView, resolve to calling compare_helper(). Change-Id: Ia7de1a095e3e310bd1b9957ed67291cc9cc95b32 Reviewed-by: David Faure --- src/corelib/tools/qcollator_icu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/tools/qcollator_icu.cpp index 3cde3051b4..1e94798c5b 100644 --- a/src/corelib/tools/qcollator_icu.cpp +++ b/src/corelib/tools/qcollator_icu.cpp @@ -110,7 +110,7 @@ int QCollator::compare(const QChar *s1, int len1, const QChar *s2, int len2) con if (d->collator) return ucol_strcoll(d->collator, (const UChar *)s1, len1, (const UChar *)s2, len2); - return QString::compare(QString(s1, len1), QString(s2, len2), d->caseSensitivity); + return QString::compare_helper(s1, len1, s2, len2, d->caseSensitivity); } int QCollator::compare(const QString &s1, const QString &s2) const -- cgit v1.2.3 From 9e5e30fa130e43524d9ff26493023ac966a878cc Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 5 Feb 2017 14:55:01 +0100 Subject: QStringMatcher: fix setCaseSensitivity() on a non-QString-backed matcher When a non-QString-backed mode (via the (QChar*, int) ctor) was added for Qt 4.5, the author forgot to adjust the setCaseSensitivity() function. It still uses q_pattern instead of (p.uc, p.len) as the pattern for which to create the skip-table. Since there is no setPattern() overload for this mode, the correctness of the matcher is not harmed by this, but its performance degrades to that of a linear scan: the skip-table, being filled from an empty pattern, will be all-zeros, sending bm_find() into the 'possible match' case at every character. Since matching is still correct, but slow, it's not possible to write a test for this. I did, however, leave my attempts in the auto-test, for when we add QStringView overloads of setPattern() which will then be able to expose the bug. Change-Id: I7b803e8624b0352a0a974900affbbfc0c260d93b Reviewed-by: Giuseppe D'Angelo Reviewed-by: Edward Welbourne --- src/corelib/tools/qstringmatcher.cpp | 2 +- .../corelib/tools/qstringmatcher/tst_qstringmatcher.cpp | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qstringmatcher.cpp b/src/corelib/tools/qstringmatcher.cpp index 67e7ad3825..67d3f0ebc8 100644 --- a/src/corelib/tools/qstringmatcher.cpp +++ b/src/corelib/tools/qstringmatcher.cpp @@ -252,7 +252,7 @@ void QStringMatcher::setCaseSensitivity(Qt::CaseSensitivity cs) { if (cs == q_cs) return; - bm_init_skiptable((const ushort *)q_pattern.unicode(), q_pattern.size(), p.q_skiptable, cs); + bm_init_skiptable((const ushort *)p.uc, p.len, p.q_skiptable, cs); q_cs = cs; } diff --git a/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp b/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp index 0c098cb1c3..8a55f54449 100644 --- a/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp +++ b/tests/auto/corelib/tools/qstringmatcher/tst_qstringmatcher.cpp @@ -54,12 +54,21 @@ void tst_QStringMatcher::qstringmatcher() // public Qt::CaseSensitivity caseSensitivity() const void tst_QStringMatcher::caseSensitivity() { - QStringMatcher matcher; + const QString haystack = QStringLiteral("foobarFoo"); + const QStringRef needle = haystack.rightRef(3); // "Foo" + QStringMatcher matcher(needle.data(), needle.size()); - matcher.setCaseSensitivity(Qt::CaseSensitive); QCOMPARE(matcher.caseSensitivity(), Qt::CaseSensitive); + QCOMPARE(matcher.indexIn(haystack), 6); + matcher.setCaseSensitivity(Qt::CaseInsensitive); + QCOMPARE(matcher.caseSensitivity(), Qt::CaseInsensitive); + QCOMPARE(matcher.indexIn(haystack), 0); + + matcher.setCaseSensitivity(Qt::CaseSensitive); + QCOMPARE(matcher.caseSensitivity(), Qt::CaseSensitive); + QCOMPARE(matcher.indexIn(haystack), 6); } void tst_QStringMatcher::indexIn_data() -- cgit v1.2.3 From e6a67bb9ec87f4a49769478aca6e8b9b08f7f5fb Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 16 Jun 2016 12:22:55 -0700 Subject: Update the mkspec for win32-icc to use the MSVC config files Change-Id: Ib57b52598e2f452985e9fffd1458a6b534111c23 Reviewed-by: Oswald Buddenhagen --- mkspecs/win32-icc/qmake.conf | 56 +++++--------------------------------------- 1 file changed, 6 insertions(+), 50 deletions(-) diff --git a/mkspecs/win32-icc/qmake.conf b/mkspecs/win32-icc/qmake.conf index cfd8399a3c..dcbbc027ea 100644 --- a/mkspecs/win32-icc/qmake.conf +++ b/mkspecs/win32-icc/qmake.conf @@ -4,27 +4,19 @@ # Written for Intel C++ # -include(../common/angle.conf) +# Use the Visual Studio configuration -MAKEFILE_GENERATOR = MSVC.NET -QMAKE_PLATFORM = win32 -CONFIG += incremental flat debug_and_release debug_and_release_target -DEFINES += UNICODE -QMAKE_COMPILER_DEFINES += __INTEL_COMPILER WIN32 +include(../common/msvc-desktop.conf) -QMAKE_COMPILER = msvc intel_icl # icl pretends to be msvc +# Now override with the Intel compiler settings + +QMAKE_COMPILER += intel_icl # icl pretends to be msvc QMAKE_CC = icl -QMAKE_LEX = flex -QMAKE_LEXFLAGS = -QMAKE_YACC = bison -y -QMAKE_YACCFLAGS = -d QMAKE_CFLAGS = -nologo -Zm200 /Qprec /Qwd1744,1738,809,3373 QMAKE_CFLAGS_WARN_ON = -W3 /Qwd673 QMAKE_CFLAGS_WARN_OFF = -W0 /Qwd673 -QMAKE_CFLAGS_RELEASE = -O2 -MD QMAKE_CFLAGS_DEBUG = -Zi -MDd -Od -QMAKE_CFLAGS_YACC = QMAKE_CFLAGS_LTCG = -Qipo QMAKE_CFLAGS_DISABLE_LTCG = -Qno-ipo QMAKE_CFLAGS_SSE2 = -QxSSE2 @@ -46,15 +38,6 @@ QMAKE_CXX = $$QMAKE_CC QMAKE_CXXFLAGS = $$QMAKE_CFLAGS /Zc:forScope QMAKE_CXXFLAGS_WARN_ON = $$QMAKE_CFLAGS_WARN_ON QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF -QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE -QMAKE_CXXFLAGS_DEBUG = $$QMAKE_CFLAGS_DEBUG -QMAKE_CXXFLAGS_YACC = $$QMAKE_CFLAGS_YACC -QMAKE_CXXFLAGS_STL_ON = -GX -QMAKE_CXXFLAGS_STL_OFF = -QMAKE_CXXFLAGS_RTTI_ON = -GR -QMAKE_CXXFLAGS_RTTI_OFF = -QMAKE_CXXFLAGS_EXCEPTIONS_ON = -EHsc -QMAKE_CXXFLAGS_EXCEPTIONS_OFF = QMAKE_CXXFLAGS_CXX11 = -Qstd=c++11 # ICC supports the following but Qt won't compile #QMAKE_CXXFLAGS_CXX14 = -Qstd=c++14 @@ -62,41 +45,14 @@ QMAKE_CXXFLAGS_CXX11 = -Qstd=c++11 QMAKE_CXXFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG QMAKE_CXXFLAGS_DISABLE_LTCG = $$QMAKE_CFLAGS_DISABLE_LTCG -QMAKE_INCDIR = - -QMAKE_RUN_CC = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CC_IMP = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CC_IMP_BATCH = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<< -QMAKE_RUN_CXX = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src -QMAKE_RUN_CXX_IMP = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $< -QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<< - QMAKE_LINK = xilink QMAKE_LFLAGS = /NOLOGO QMAKE_LFLAGS_RELEASE = +QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO = QMAKE_LFLAGS_DEBUG = /DEBUG -QMAKE_LFLAGS_CONSOLE = /SUBSYSTEM:console -QMAKE_LFLAGS_WINDOWS = /SUBSYSTEM:windows -QMAKE_LFLAGS_DLL = /DLL QMAKE_LFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG -QMAKE_PREFIX_SHLIB = -QMAKE_EXTENSION_SHLIB = dll -QMAKE_PREFIX_STATICLIB = -QMAKE_EXTENSION_STATICLIB = lib - -QMAKE_LIBS = -QMAKE_LIBS_CORE = kernel32.lib user32.lib shell32.lib uuid.lib ole32.lib advapi32.lib ws2_32.lib -QMAKE_LIBS_GUI = gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib ws2_32.lib ole32.lib user32.lib advapi32.lib -QMAKE_LIBS_NETWORK = ws2_32.lib -QMAKE_LIBS_OPENGL = glu32.lib opengl32.lib gdi32.lib user32.lib delayimp.lib -QMAKE_LIBS_OPENGL_ES2 = $${LIBEGL_NAME}.lib $${LIBGLESV2_NAME}.lib gdi32.lib user32.lib -QMAKE_LIBS_OPENGL_ES2_DEBUG = $${LIBEGL_NAME}d.lib $${LIBGLESV2_NAME}d.lib gdi32.lib user32.lib -QMAKE_LIBS_COMPAT = advapi32.lib shell32.lib comdlg32.lib user32.lib gdi32.lib ws2_32.lib -QMAKE_LIBS_QT_ENTRY = -lqtmain -QMAKE_IDL = midl QMAKE_LIB = xilib /NOLOGO -QMAKE_RC = rc DSP_EXTENSION = .dsp load(qt_config) -- cgit v1.2.3 From 8798d03e7ef917ae345a673da9abfee4f0a65795 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 6 Feb 2017 11:10:19 -0800 Subject: Remove unused qt_application_thread_id variable Seems to be a write-only variable and QThread::currentThreadId has no side-effects. Change-Id: Ifaee7464122d402991b6fffd14a0c8666968dfe4 Reviewed-by: Friedemann Kleint Reviewed-by: Marc Mutz --- src/corelib/kernel/qcoreapplication.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 3796df5614..96167b4508 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -318,10 +318,6 @@ Q_CORE_EXPORT uint qGlobalPostedEventsCount() QAbstractEventDispatcher *QCoreApplicationPrivate::eventDispatcher = 0; -#ifdef Q_OS_UNIX -Qt::HANDLE qt_application_thread_id = 0; -#endif - #endif // QT_NO_QOBJECT QCoreApplication *QCoreApplication::self = 0; @@ -431,10 +427,6 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint qFatal("FATAL: The application binary appears to be running setuid, this is a security hole."); # endif // Q_OS_UNIX -# if defined(Q_OS_UNIX) - qt_application_thread_id = QThread::currentThreadId(); -# endif - QThread *cur = QThread::currentThread(); // note: this may end up setting theMainThread! if (cur != theMainThread) qWarning("WARNING: QApplication was not created in the main() thread."); -- cgit v1.2.3 From b6bf2a33f4c33a212da7b58a049b3b5b20b3f327 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 7 Feb 2017 13:45:20 -0800 Subject: Remove outdated check for Apple Clang 2.x and 3.x The minimum version of Xcode that we support is 5.1 (based on Clang 3.4) Change-Id: I536c32a88bff44dab37afffd14a11f709fb25169 Reviewed-by: Jake Petroules --- configure.json | 6 +----- configure.pri | 12 ------------ 2 files changed, 1 insertion(+), 17 deletions(-) diff --git a/configure.json b/configure.json index 9a9645a23a..c69c2ac0f8 100644 --- a/configure.json +++ b/configure.json @@ -314,10 +314,6 @@ "type": "compile", "test": "common/avx" }, - "avx_apple_clang": { - "label": "bugfree AVX support in compiler", - "type": "avx_test_apple_clang" - }, "avx2": { "label": "AVX2 instructions", "type": "compile", @@ -751,7 +747,7 @@ }, "avx": { "label": "AVX", - "condition": "features.sse4_2 && tests.avx && tests.avx_apple_clang", + "condition": "features.sse4_2 && tests.avx", "output": [ "privateConfig", { "type": "define", "name": "QT_COMPILER_SUPPORTS_AVX", "value": 1 } diff --git a/configure.pri b/configure.pri index 74eef36667..a5e77411ee 100644 --- a/configure.pri +++ b/configure.pri @@ -274,18 +274,6 @@ defineTest(qtConfTest_architecture) { return(true) } -defineTest(qtConfTest_avx_test_apple_clang) { - !*g++*:!*-clang*: return(true) - - qtRunLoggedCommand("$$QMAKE_CXX --version", compiler)|return(false) - contains(compiler, "Apple clang version [23]") { - # Some clang versions produce internal compiler errors compiling Qt AVX code - return(false) - } else { - return(true) - } -} - defineTest(qtConfTest_gnumake) { make = $$qtConfFindInPath("gmake") isEmpty(make): make = $$qtConfFindInPath("make") -- cgit v1.2.3