mp_msg.c: Avoid out-of-bounds read if empty string is printed

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31626 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2010-07-02 23:43:09 +00:00 committed by Uoti Urpala
parent 61ed4c2945
commit 63b69b312c
1 changed files with 3 additions and 1 deletions

View File

@ -234,7 +234,9 @@ void mp_msg_va(int mod, int lev, const char *format, va_list va)
if (header)
print_msg_module(stream, mod);
set_msg_color(stream, lev);
header = tmp[strlen(tmp)-1] == '\n' || tmp[strlen(tmp)-1] == '\r';
size_t len = strlen(tmp);
header = len && (tmp[len-1] == '\n' || tmp[len-1] == '\r');
fprintf(stream, "%s", tmp);
if (mp_msg_color)