Skip to content

Commit 6ff5b5d

Browse files
pm215kraxel
authored andcommitted
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 <[email protected]> Message-Id: <[email protected]> Signed-off-by: Gerd Hoffmann <[email protected]>
1 parent da77adb commit 6ff5b5d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ui/sdl2.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,10 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
817817
* This is a bit hackish but saves us from bigger problem.
818818
* Maybe it's a good idea to fix this in SDL instead.
819819
*/
820-
g_setenv("SDL_VIDEODRIVER", "x11", 0);
820+
if (!g_setenv("SDL_VIDEODRIVER", "x11", 0)) {
821+
fprintf(stderr, "Could not set SDL_VIDEODRIVER environment variable\n");
822+
exit(1);
823+
}
821824
#endif
822825

823826
if (SDL_Init(SDL_INIT_VIDEO)) {

0 commit comments

Comments
 (0)