fix uninitialized warnings in KMSDRM_CreateCursor()

This commit is contained in:
Ozkan Sezer 2020-12-21 01:20:30 +03:00
parent a8dbcab132
commit 4198f0e52c

View File

@ -106,6 +106,9 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
KMSDRM_CursorData *curdata; KMSDRM_CursorData *curdata;
SDL_Cursor *cursor, *ret; SDL_Cursor *cursor, *ret;
curdata = NULL;
ret = NULL;
/* All code below assumes ARGB8888 format for the cursor surface, /* All code below assumes ARGB8888 format for the cursor surface,
like other backends do. Also, the GBM BO pixels have to be like other backends do. Also, the GBM BO pixels have to be
alpha-premultiplied, but the SDL surface we receive has alpha-premultiplied, but the SDL surface we receive has
@ -116,13 +119,11 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor)); cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(*cursor));
if (!cursor) { if (!cursor) {
SDL_OutOfMemory(); SDL_OutOfMemory();
ret = NULL;
goto cleanup; goto cleanup;
} }
curdata = (KMSDRM_CursorData *) SDL_calloc(1, sizeof(*curdata)); curdata = (KMSDRM_CursorData *) SDL_calloc(1, sizeof(*curdata));
if (!curdata) { if (!curdata) {
SDL_OutOfMemory(); SDL_OutOfMemory();
ret = NULL;
goto cleanup; goto cleanup;
} }
@ -164,15 +165,15 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
cleanup: cleanup:
if (ret == NULL) { if (ret == NULL) {
if (curdata->buffer) { if (curdata) {
SDL_free(curdata->buffer); if (curdata->buffer) {
SDL_free(curdata->buffer);
}
SDL_free(curdata);
} }
if (cursor) { if (cursor) {
SDL_free(cursor); SDL_free(cursor);
} }
if (curdata) {
SDL_free(curdata);
}
} }
return ret; return ret;