1
mirror of https://github.com/mpv-player/mpv synced 2024-10-30 04:46:41 +01:00

msg: handle vsnprintf errors

I don't know under which circumstances this can error (other than a
broken format string). It seems it won't return an error code on I/O
errors, so maybe broken format strings are the only case. Either way,
don't continue if an error is returned.
This commit is contained in:
wm4 2013-12-20 21:07:16 +01:00
parent e9e68fc399
commit ad05e76c57

View File

@ -155,7 +155,8 @@ void mp_msg_log_va(struct mp_log *log, int lev, const char *format, va_list va)
FILE *stream = (mp_msg_stdout_in_use || lev == MSGL_STATUS) ? stderr : stdout;
char tmp[MSGSIZE_MAX];
vsnprintf(tmp, MSGSIZE_MAX, format, va);
if (vsnprintf(tmp, MSGSIZE_MAX, format, va) < 0)
snprintf(tmp, MSGSIZE_MAX, "[fprintf error]\n");
tmp[MSGSIZE_MAX - 2] = '\n';
tmp[MSGSIZE_MAX - 1] = 0;