@@ -205,39 +205,30 @@ static HBITMAP CreateMaskBitmap(SDL_Surface *surface, bool is_monochrome)
205
205
206
206
static HCURSOR WIN_CreateHCursor (SDL_Surface * surface , int hot_x , int hot_y )
207
207
{
208
- HCURSOR hcursor ;
209
- ICONINFO ii ;
208
+ HCURSOR hcursor = NULL ;
210
209
bool is_monochrome = IsMonochromeSurface (surface );
211
-
212
- SDL_zero ( ii );
213
- ii . fIcon = FALSE;
214
- ii . xHotspot = (DWORD )hot_x ;
215
- ii . yHotspot = ( DWORD ) hot_y ;
216
- ii . hbmMask = CreateMaskBitmap (surface , is_monochrome );
217
- ii . hbmColor = is_monochrome ? NULL : CreateColorBitmap ( surface ) ;
210
+ ICONINFO ii = {
211
+ . fIcon = FALSE,
212
+ . xHotspot = ( DWORD ) hot_x ,
213
+ . yHotspot = (DWORD )hot_y ,
214
+ . hbmMask = CreateMaskBitmap ( surface , is_monochrome ),
215
+ . hbmColor = is_monochrome ? NULL : CreateColorBitmap (surface )
216
+ } ;
218
217
219
218
if (!ii .hbmMask || (!is_monochrome && !ii .hbmColor )) {
220
219
SDL_SetError ("Couldn't create cursor bitmaps" );
221
- if (ii .hbmMask ) {
222
- DeleteObject (ii .hbmMask );
223
- }
224
- if (ii .hbmColor ) {
225
- DeleteObject (ii .hbmColor );
226
- }
227
- return NULL ;
220
+ goto cleanup ;
228
221
}
229
222
230
223
hcursor = CreateIconIndirect (& ii );
231
224
if (!hcursor ) {
232
- WIN_SetError ("CreateIconIndirect()" );
233
- DeleteObject (ii .hbmMask );
234
- if (ii .hbmColor ) {
235
- DeleteObject (ii .hbmColor );
236
- }
237
- return NULL ;
225
+ WIN_SetError ("CreateIconIndirect failed" );
238
226
}
239
227
240
- DeleteObject (ii .hbmMask );
228
+ cleanup :
229
+ if (ii .hbmMask ) {
230
+ DeleteObject (ii .hbmMask );
231
+ }
241
232
if (ii .hbmColor ) {
242
233
DeleteObject (ii .hbmColor );
243
234
}
0 commit comments