1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-14 13:41:12 +00:00

Fix memory leak in set_custom_mouse_cursor

This commit is contained in:
Guilherme Felipe
2018-05-26 15:54:38 -03:00
parent 2f56eb9bb8
commit dda8937ef3
3 changed files with 17 additions and 5 deletions

View File

@@ -2017,7 +2017,7 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap
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);
for (UINT index = 0; index < image_size; index++) {
int row_index = floor(index / texture_size.width) + atlas_rect.pos.y;
@@ -2042,6 +2042,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;
}
@@ -2066,6 +2068,9 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap
if (hXorMask != NULL) {
DeleteObject(hXorMask);
}
memfree(buffer);
DeleteObject(bitmap);
}
}