From 1c8396abef04df68fd03d2fb6c32e466db1f8457 Mon Sep 17 00:00:00 2001 From: Jiaqing Zhao Date: Mon, 3 Jul 2023 06:30:03 +0000 Subject: [PATCH] dm: vdisplay_sdl: fix command line option parsing strcasestr() returns NULL if specified substring is not found, which should be handled when parsing the command line options. Tracked-On: #8439 Signed-off-by: Jiaqing Zhao Reviewed-by: Jian Jun Chen --- devicemodel/hw/vdisplay_sdl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/devicemodel/hw/vdisplay_sdl.c b/devicemodel/hw/vdisplay_sdl.c index 8842acded..4e53e9c9f 100644 --- a/devicemodel/hw/vdisplay_sdl.c +++ b/devicemodel/hw/vdisplay_sdl.c @@ -1378,8 +1378,7 @@ int vdpy_parse_cmd_option(const char *opts) stropts = strdup(opts); while ((str = strsep(&stropts, ",")) != NULL) { vscr = vdpy.vscrs + vdpy.vscrs_num; - tmp = strcasestr(str, "geometry="); - if (str && strcasestr(str, "geometry=fullscreen")) { + if ((tmp = strcasestr(str, "geometry=fullscreen")) != NULL) { snum = sscanf(tmp, "geometry=fullscreen:%d", &vscr->pscreen_id); if (snum != 1) { vscr->pscreen_id = 0; @@ -1392,7 +1391,7 @@ int vdpy_parse_cmd_option(const char *opts) pr_info("virtual display: fullscreen on monitor %d.\n", vscr->pscreen_id); vdpy.vscrs_num++; - } else if (str && strcasestr(str, "geometry=")) { + } else if ((tmp = strcasestr(str, "geometry=")) != NULL) { snum = sscanf(tmp, "geometry=%dx%d+%d+%d", &vscr->guest_width, &vscr->guest_height, &vscr->org_x, &vscr->org_y);