mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 10:10:57 +00:00
fix logging on Windows sometimes not being null-terminated
This commit is contained in:
parent
20846796cd
commit
f51e50a423
@ -357,12 +357,14 @@ static void create_gl_context(HWND hwnd, bool *quit)
|
||||
wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC))
|
||||
gfx_ctx_wgl_get_proc_address("wglGetExtensionsStringARB");
|
||||
if (wglGetExtensionsStringARB)
|
||||
extensions = wglGetExtensionsStringARB(win32_hdc);
|
||||
RARCH_LOG("[WGL] extensions: %s\n", extensions);
|
||||
if (wgl_has_extension("WGL_EXT_swap_control_tear", extensions))
|
||||
{
|
||||
RARCH_LOG("[WGL]: Adaptive VSync supported.\n");
|
||||
wgl_adaptive_vsync = true;
|
||||
extensions = wglGetExtensionsStringARB(win32_hdc);
|
||||
RARCH_LOG("[WGL] extensions: %s\n", extensions);
|
||||
if (wgl_has_extension("WGL_EXT_swap_control_tear", extensions))
|
||||
{
|
||||
RARCH_LOG("[WGL]: Adaptive VSync supported.\n");
|
||||
wgl_adaptive_vsync = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
20
verbosity.c
20
verbosity.c
@ -218,9 +218,27 @@ void RARCH_LOG_V(const char *tag, const char *fmt, va_list ap)
|
||||
#else
|
||||
FILE *fp = (FILE*)log_file_fp;
|
||||
#if defined(HAVE_QT) || defined(__WINRT__)
|
||||
int ret;
|
||||
char buffer[256];
|
||||
buffer[0] = '\0';
|
||||
vsnprintf(buffer, sizeof(buffer), fmt, ap);
|
||||
ret = vsnprintf(buffer, sizeof(buffer), fmt, ap);
|
||||
|
||||
/* ensure null termination and line break in error case */
|
||||
if (ret < 0)
|
||||
{
|
||||
int end;
|
||||
buffer[sizeof buffer - 1] = '\0';
|
||||
end = strlen(buffer) - 1;
|
||||
if (end >= 0)
|
||||
{
|
||||
buffer[end] = '\n';
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer[0] = '\n';
|
||||
buffer[1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (fp)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user