avutil/log: check that len is within the buffer before reading it

Fixes out of array read
Fixes: asan_heap-oob_19d6979_6857_mmw_deadzy.ogg
Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-11-27 17:04:05 +01:00
parent 6b58488f92
commit 808c10e728
1 changed files with 1 additions and 1 deletions

View File

@ -200,7 +200,7 @@ static void format_line(void *ptr, int level, const char *fmt, va_list vl,
av_vbprintf(part+2, fmt, vl);
if(*part[0].str || *part[1].str || *part[2].str) {
char lastc = part[2].len ? part[2].str[part[2].len - 1] : 0;
char lastc = part[2].len && part[2].len <= part[2].size ? part[2].str[part[2].len - 1] : 0;
*print_prefix = lastc == '\n' || lastc == '\r';
}
}