avio_put_str16le: Print error message in case of invalid UTF8 input

Found-by: Stefano Sabatini
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-11-13 18:39:17 +01:00
parent 7561974dfe
commit b52ae27edf
1 changed files with 4 additions and 1 deletions

View File

@ -324,8 +324,11 @@ int avio_put_str16le(AVIOContext *s, const char *str)
uint32_t ch; uint32_t ch;
uint16_t tmp; uint16_t tmp;
GET_UTF8(ch, *q++, break;) GET_UTF8(ch, *q++, goto invalid;)
PUT_UTF16(ch, tmp, avio_wl16(s, tmp); ret += 2;) PUT_UTF16(ch, tmp, avio_wl16(s, tmp); ret += 2;)
continue;
invalid:
av_log(s, AV_LOG_ERROR, "Invaid UTF8 sequence in avio_put_str16le\n");
} }
avio_wl16(s, 0); avio_wl16(s, 0);
ret += 2; ret += 2;