From 2f823eb6a7a4e73ce2c58acab487718330d94a46 Mon Sep 17 00:00:00 2001 From: Guilherme Felipe Date: Tue, 8 May 2018 15:01:21 +0000 Subject: [PATCH] Prevent crash for invalid reference --- platform/osx/os_osx.mm | 4 ++-- platform/windows/os_windows.cpp | 2 +- platform/x11/os_x11.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index d20f792e03c..c9a07f34ea5 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1216,7 +1216,7 @@ void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c texture_size.width = atlas_texture->get_region().size.x; texture_size.height = atlas_texture->get_region().size.y; - } else { + } else if (texture.is_valid()) { texture_size.width = texture->get_width(); texture_size.height = texture->get_height(); } @@ -1257,7 +1257,7 @@ void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c uint32_t color = image.get_pixel(column_index, row_index).to_ARGB32(); uint8_t alpha = (color >> 24) & 0xFF; - pixels[i * 4 + 0] = ((color >> 16) & 0xFF) * alpha / 255; + pixels[i * 4 + 0] = ((color >> 16) & 0xFF) * alpha / 255; pixels[i * 4 + 1] = ((color >> 8) & 0xFF) * alpha / 255; pixels[i * 4 + 2] = ((color) & 0xFF) * alpha / 255; pixels[i * 4 + 3] = alpha; diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 03c8995a44f..357ade8a919 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2003,7 +2003,7 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap texture_size.width = atlas_texture->get_region().size.x; texture_size.height = atlas_texture->get_region().size.y; - } else { + } else if (texture.is_valid()) { texture_size.width = texture->get_width(); texture_size.height = texture->get_height(); } diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 5d2e11c2d5c..3356c8341d1 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -2177,7 +2177,7 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c texture_size.width = atlas_texture->get_region().size.x; texture_size.height = atlas_texture->get_region().size.y; - } else { + } else if (texture.is_valid()) { texture_size.width = texture->get_width(); texture_size.height = texture->get_height(); }