mirror of
https://github.com/godotengine/godot.git
synced 2025-12-08 06:09:55 +00:00
Fix memory leak in set_custom_mouse_cursor
This commit is contained in:
parent
2f56eb9bb8
commit
dda8937ef3
3 changed files with 17 additions and 5 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue