diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 939ea5dbde..902cf75c45 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -635,15 +635,14 @@ static bool win32_browser( char new_title[PATH_MAX]; char new_file[32768]; + new_title[0] = '\0'; + new_file[0] = '\0'; + if (!string_is_empty(title)) strlcpy(new_title, title, sizeof(new_title)); - else - new_title[0] = '\0'; if (filename && *filename) strlcpy(new_file, filename, sizeof(new_file)); - else - new_file[0] = '\0'; /* OPENFILENAME.lpstrFilters is actually const, * so this cast should be safe */ @@ -2346,6 +2345,7 @@ void win32_update_title(void) if (window) { char title[128]; + title[0] = '\0'; video_driver_get_window_title(title, sizeof(title)); update_title_wait = g_win32_refresh_rate; if (title[0]) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 81f80e2940..d556947293 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -203,27 +203,24 @@ static void xdg_screensaver_inhibit(Window wnd) { int ret; char cmd[64]; + char title[128]; - cmd[0] = '\0'; + cmd[0] = '\0'; + title[0] = '\0'; RARCH_LOG("[X11]: Suspending screensaver (X11, xdg-screensaver).\n"); if (g_x11_dpy && g_x11_win) { - char title[128]; - size_t title_len; /* Make sure the window has a title, even if it's a bogus one, otherwise * xdg-screensaver will fail and report to stderr, framing RA for its bug. * A single space character is used so that the title bar stays visibly * the same, as if there's no title at all. */ video_driver_get_window_title(title, sizeof(title)); - if ((title_len = strlen(title)) == 0) - { - title[0] = ' '; - title[1] = '\0'; - } + if (strlen(title) == 0) + snprintf(title, sizeof(title), " "); XChangeProperty(g_x11_dpy, g_x11_win, XA_WM_NAME, XA_STRING, - 8, PropModeReplace, (const unsigned char*) title, title_len); + 8, PropModeReplace, (const unsigned char*) title, strlen(title)); } snprintf(cmd, sizeof(cmd), "xdg-screensaver suspend 0x%x", (int)wnd); @@ -767,6 +764,7 @@ bool x11_connect(void) void x11_update_title(void *data) { char title[128]; + title[0] = '\0'; video_driver_get_window_title(title, sizeof(title)); if (title[0]) XChangeProperty(g_x11_dpy, g_x11_win, XA_WM_NAME, XA_STRING,