diff --git a/common/av_log.c b/common/av_log.c index 7e0b271c81..bfd9a836e8 100644 --- a/common/av_log.c +++ b/common/av_log.c @@ -131,12 +131,17 @@ static void mp_msg_av_log_callback(void *ptr, int level, const char *fmt, struct mp_log *log = get_av_log(ptr); if (mp_msg_test(log, mp_level)) { + char buffer[4096] = ""; + int pos = 0; const char *prefix = avc ? avc->item_name(ptr) : NULL; if (log_print_prefix && prefix) - mp_msg(log, mp_level, "%s: ", prefix); + pos = snprintf(buffer, sizeof(buffer), "%s: ", prefix); log_print_prefix = fmt[strlen(fmt) - 1] == '\n'; - mp_msg_va(log, mp_level, fmt, vl); + pos = MPMIN(MPMAX(pos, 0), sizeof(buffer)); + vsnprintf(buffer + pos, sizeof(buffer) - pos, fmt, vl); + + mp_msg(log, mp_level, "%s", buffer); } pthread_mutex_unlock(&log_lock);