mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-06-03 17:08:08 -04:00
xcf: Don't crash with files with unsupported layer modes
This commit is contained in:
parent
af7a89fea7
commit
bd704045e6
@ -244,6 +244,12 @@ bool XCFImageFormat::random_table_initialized;
|
|||||||
|
|
||||||
QVector<QRgb> XCFImageFormat::grayTable;
|
QVector<QRgb> XCFImageFormat::grayTable;
|
||||||
|
|
||||||
|
template <typename T, size_t N>
|
||||||
|
constexpr size_t countof(T(&)[N])
|
||||||
|
{
|
||||||
|
return N;
|
||||||
|
}
|
||||||
|
|
||||||
const XCFImageFormat::LayerModes XCFImageFormat::layer_modes[] = {
|
const XCFImageFormat::LayerModes XCFImageFormat::layer_modes[] = {
|
||||||
{true}, // NORMAL_MODE
|
{true}, // NORMAL_MODE
|
||||||
{true}, // DISSOLVE_MODE
|
{true}, // DISSOLVE_MODE
|
||||||
@ -709,6 +715,10 @@ bool XCFImageFormat::loadLayerProperties(QDataStream &xcf_io, Layer &layer)
|
|||||||
|
|
||||||
case PROP_MODE:
|
case PROP_MODE:
|
||||||
property >> layer.mode;
|
property >> layer.mode;
|
||||||
|
if (layer.mode >= countof(layer_modes)) {
|
||||||
|
qWarning() << "Found layer with unsupported mode" << layer.mode << "Defaulting to mode 0";
|
||||||
|
layer.mode = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_TATTOO:
|
case PROP_TATTOO:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user