summary refs log tree commit diff stats
path: root/ui/sdl2.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2021-08-09 17:14:24 +0100
committerGerd Hoffmann <kraxel@redhat.com>2021-08-10 10:56:39 +0200
commit6ff5b5d6d521001135d1bd5c609e8834099f01d8 (patch)
tree48c94b752e4ba1f2346b6d2329d02a515ef9cfc7 /ui/sdl2.c
parentda77adbaf619c4d170cb42d769145ad1803fbad9 (diff)
downloadfocaccia-qemu-6ff5b5d6d521001135d1bd5c609e8834099f01d8.tar.gz
focaccia-qemu-6ff5b5d6d521001135d1bd5c609e8834099f01d8.zip
ui/sdl2: Check return value from g_setenv()
Setting environment variables can fail; check the return value
from g_setenv() and bail out if we couldn't set SDL_VIDEODRIVER.

Fixes: Coverity 1458798
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20210809161424.32355-1-peter.maydell@linaro.org>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'ui/sdl2.c')
-rw-r--r--ui/sdl2.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/ui/sdl2.c b/ui/sdl2.c
index 36d9010cb6..17c0ec30eb 100644
--- a/ui/sdl2.c
+++ b/ui/sdl2.c
@@ -817,7 +817,10 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
      * This is a bit hackish but saves us from bigger problem.
      * Maybe it's a good idea to fix this in SDL instead.
      */
-    g_setenv("SDL_VIDEODRIVER", "x11", 0);
+    if (!g_setenv("SDL_VIDEODRIVER", "x11", 0)) {
+        fprintf(stderr, "Could not set SDL_VIDEODRIVER environment variable\n");
+        exit(1);
+    }
 #endif
 
     if (SDL_Init(SDL_INIT_VIDEO)) {