diff options
author | wm4 <wm4@nowhere> | 2013-12-20 21:07:16 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-12-20 21:07:58 +0100 |
commit | ad05e76c57820eb93a21f8e4185f36f58ec2c1fc (patch) | |
tree | 75c754e9a9387cc1b92d34df329730af15784738 /common | |
parent | e9e68fc399ed2805b43dff8f355142804e55c38c (diff) |
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.
Diffstat (limited to 'common')
-rw-r--r-- | common/msg.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/common/msg.c b/common/msg.c index 6d4e374a24..926d9f06fc 100644 --- a/common/msg.c +++ b/common/msg.c @@ -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; |