1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-15 13:51:40 +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

@@ -2198,7 +2198,7 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
cursor_image->yhot = p_hotspot.y;
// allocate memory to contain the whole file
cursor_image->pixels = (XcursorPixel *)malloc(size);
cursor_image->pixels = (XcursorPixel *)memalloc(size);
for (XcursorPixel index = 0; index < image_size; index++) {
int row_index = floor(index / texture_size.width) + atlas_rect.pos.y;
@@ -2220,6 +2220,9 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
if (p_shape == CURSOR_ARROW) {
XDefineCursor(x11_display, x11_window, cursors[p_shape]);
}
memfree(cursor_image->pixels);
XcursorImageDestroy(cursor_image);
}
}