summaryrefslogtreecommitdiff
path: root/platform/windows
diff options
context:
space:
mode:
authorMax Hilbrunner <mhilbrunner@users.noreply.github.com>2018-05-28 12:49:34 +0200
committerGitHub <noreply@github.com>2018-05-28 12:49:34 +0200
commitdaa136784d69c224fa60161a8f9d5494e56e9ced (patch)
tree320168e7c3608069157adb4ef9538ab802cf6c2e /platform/windows
parentbce002f5c3555080cc9edec7fa6650c9f072e632 (diff)
parentaa174d963df943ba8a763a57a51888e3a37c2fe0 (diff)
Merge pull request #19181 from guilhermefelipecgs/fix_memory_leak
Fix memory leak in set_custom_mouse_cursor
Diffstat (limited to 'platform/windows')
-rw-r--r--platform/windows/os_windows.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index 8d664b5832..af03432838 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -2081,7 +2081,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);
image->lock();
for (UINT index = 0; index < image_size; index++) {
@@ -2108,6 +2108,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 +2134,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;