@@ -205,39 +205,30 @@ static HBITMAP CreateMaskBitmap(SDL_Surface *surface, bool is_monochrome)
205205
206206static HCURSOR WIN_CreateHCursor (SDL_Surface * surface , int hot_x , int hot_y )
207207{
208- HCURSOR hcursor ;
209- ICONINFO ii ;
208+ HCURSOR hcursor = NULL ;
210209 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+ } ;
218217
219218 if (!ii .hbmMask || (!is_monochrome && !ii .hbmColor )) {
220219 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 ;
228221 }
229222
230223 hcursor = CreateIconIndirect (& ii );
231224 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" );
238226 }
239227
240- DeleteObject (ii .hbmMask );
228+ cleanup :
229+ if (ii .hbmMask ) {
230+ DeleteObject (ii .hbmMask );
231+ }
241232 if (ii .hbmColor ) {
242233 DeleteObject (ii .hbmColor );
243234 }
0 commit comments