You've already forked godot
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user