diff options
Diffstat (limited to 'platform/windows/os_windows.cpp')
-rw-r--r-- | platform/windows/os_windows.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 8d664b5832..aef1b8a595 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -2077,11 +2077,13 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap image = texture->get_data(); + ERR_FAIL_COND(!image.is_valid()); + UINT image_size = texture_size.width * texture_size.height; UINT size = sizeof(UINT) * image_size; // Create the BITMAP with alpha channel - COLORREF *buffer = (COLORREF *)malloc(sizeof(COLORREF) * image_size); + COLORREF *buffer = (COLORREF *)memalloc(sizeof(COLORREF) * image_size); image->lock(); for (UINT index = 0; index < image_size; index++) { @@ -2108,6 +2110,8 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap GetMaskBitmaps(bitmap, clrTransparent, hAndMask, hXorMask); if (NULL == hAndMask || NULL == hXorMask) { + memfree(buffer); + DeleteObject(bitmap); return; } @@ -2132,6 +2136,9 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap if (hXorMask != NULL) { DeleteObject(hXorMask); } + + memfree(buffer); + DeleteObject(bitmap); } else { // Reset to default system cursor cursors[p_shape] = NULL; |