# SDL: Always destroy icon

**URL:** <https://discourse.libsdl.org/t/sdl-always-destroy-icon/33369>\
**Category:** SDL Commits\
**Created:** [November 9, 2021, 6:22am UTC](https://discourse.libsdl.org/t/sdl-always-destroy-icon/33369 "2021-11-09T06:22:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [November 9, 2021, 6:22am UTC](https://discourse.libsdl.org/t/sdl-always-destroy-icon/33369/1 "2021-11-09T06:22:08Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/881f747d5c8026a6d4f456db60cf11e67ddd1366>

```diff
From 881f747d5c8026a6d4f456db60cf11e67ddd1366 Mon Sep 17 00:00:00 2001
From: Yufei Huang <[EMAIL REDACTED]>
Date: Tue, 9 Nov 2021 13:35:18 +0800
Subject: [PATCH] Always destroy icon

---
 src/video/windows/SDL_windowsmouse.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c
index 4c3cab1000..65263efb9f 100644
--- a/src/video/windows/SDL_windowsmouse.c
+++ b/src/video/windows/SDL_windowsmouse.c
@@ -154,8 +154,9 @@ WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
     /* The cursor returned by CreateIconIndirect does not respect system cursor size
         preference, use CopyImage to duplicate the cursor with desired sizes */
     hcursor = CopyImage(hicon, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE);
+ DestroyIcon(hicon);
+
     if (!hcursor) {
- DestroyIcon(hicon);
         WIN_SetError("CopyImage()");
         return NULL;
     }

```
