summaryrefslogtreecommitdiff
path: root/core/io
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-06-29 12:44:20 +0200
committerGitHub <noreply@github.com>2021-06-29 12:44:20 +0200
commit05336adb86574608b5ab922d20a06428331287cc (patch)
treed2b951c7c1ac7cfc7216910ea3157c7e76382dbe /core/io
parent9c6d7f840f6f226e5d422fc7697cb75ead6c401b (diff)
parent3dae9993acf489aa46ccb7a3420a2e67ee59362f (diff)
Merge pull request #49905 from pfertyk/issue-46480-image-compress-crashes-godot
Validate image formats, check if resize_to_po2 failed
Diffstat (limited to 'core/io')
-rw-r--r--core/io/image.cpp5
-rw-r--r--core/io/image.h4
2 files changed, 8 insertions, 1 deletions
diff --git a/core/io/image.cpp b/core/io/image.cpp
index 3e79b7efbc..3112dd217f 100644
--- a/core/io/image.cpp
+++ b/core/io/image.cpp
@@ -2380,6 +2380,8 @@ Error Image::decompress() {
}
Error Image::compress(CompressMode p_mode, CompressSource p_source, float p_lossy_quality) {
+ ERR_FAIL_INDEX_V_MSG(p_mode, COMPRESS_MAX, ERR_INVALID_PARAMETER, "Invalid compress mode.");
+ ERR_FAIL_INDEX_V_MSG(p_source, COMPRESS_SOURCE_MAX, ERR_INVALID_PARAMETER, "Invalid compress source.");
return compress_from_channels(p_mode, detect_used_channels(p_source), p_lossy_quality);
}
@@ -2405,6 +2407,9 @@ Error Image::compress_from_channels(CompressMode p_mode, UsedChannels p_channels
ERR_FAIL_COND_V(!_image_compress_bptc_func, ERR_UNAVAILABLE);
_image_compress_bptc_func(this, p_lossy_quality, p_channels);
} break;
+ case COMPRESS_MAX: {
+ ERR_FAIL_V(ERR_INVALID_PARAMETER);
+ } break;
}
return OK;
diff --git a/core/io/image.h b/core/io/image.h
index 060e54a308..8f1b251ac3 100644
--- a/core/io/image.h
+++ b/core/io/image.h
@@ -336,11 +336,13 @@ public:
COMPRESS_ETC,
COMPRESS_ETC2,
COMPRESS_BPTC,
+ COMPRESS_MAX,
};
enum CompressSource {
COMPRESS_SOURCE_GENERIC,
COMPRESS_SOURCE_SRGB,
- COMPRESS_SOURCE_NORMAL
+ COMPRESS_SOURCE_NORMAL,
+ COMPRESS_SOURCE_MAX,
};
Error compress(CompressMode p_mode, CompressSource p_source = COMPRESS_SOURCE_GENERIC, float p_lossy_quality = 0.7);