fix uninitialized warnings in KMSDRM_CreateCursor()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c
index 3b4b18f..e17c3c5 100644
--- a/src/video/kmsdrm/SDL_kmsdrmmouse.c
+++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c
@@ -106,6 +106,9 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
KMSDRM_CursorData *curdata;
SDL_Cursor *cursor, *ret;
+ curdata = NULL;
+ ret = NULL;
+
/* All code below assumes ARGB8888 format for the cursor surface,
like other backends do. Also, the GBM BO pixels have to be
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));
if (!cursor) {
SDL_OutOfMemory();
- ret = NULL;
goto cleanup;
}
curdata = (KMSDRM_CursorData *) SDL_calloc(1, sizeof(*curdata));
if (!curdata) {
SDL_OutOfMemory();
- ret = NULL;
goto cleanup;
}
@@ -164,15 +165,15 @@ KMSDRM_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y)
cleanup:
if (ret == NULL) {
- if (curdata->buffer) {
- SDL_free(curdata->buffer);
+ if (curdata) {
+ if (curdata->buffer) {
+ SDL_free(curdata->buffer);
+ }
+ SDL_free(curdata);
}
if (cursor) {
SDL_free(cursor);
}
- if (curdata) {
- SDL_free(curdata);
- }
}
return ret;