summaryrefslogtreecommitdiff
path: root/editor/plugins/asset_library_editor_plugin.cpp
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2020-01-15 18:29:27 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2020-01-15 22:16:12 +0800
commit43ad6e8c96c8d116714389aa0e00755ff9248575 (patch)
tree37508db37c5f28b87a730d2785c6ccbdfee22bd2 /editor/plugins/asset_library_editor_plugin.cpp
parent7c624949b5c17d6a4f503b4e299c8c717280cd23 (diff)
Fixes AssetLib crash when JPG module is disabled
JPG module is optional, so check it's existence before using.
Diffstat (limited to 'editor/plugins/asset_library_editor_plugin.cpp')
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index 5d73ffa209..bdef108ef2 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -726,9 +726,9 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByt
uint8_t jpg_signature[3] = { 255, 216, 255 };
if (r.ptr()) {
- if (memcmp(&r[0], &png_signature[0], 8) == 0) {
+ if ((memcmp(&r[0], &png_signature[0], 8) == 0) && Image::_png_mem_loader_func) {
image->copy_internals_from(Image::_png_mem_loader_func(r.ptr(), len));
- } else if (memcmp(&r[0], &jpg_signature[0], 3) == 0) {
+ } else if ((memcmp(&r[0], &jpg_signature[0], 3) == 0) && Image::_jpg_mem_loader_func) {
image->copy_internals_from(Image::_jpg_mem_loader_func(r.ptr(), len));
}
}