mirror of https://github.com/mpv-player/mpv
bstr: check strings before memcmp/strncasecmp
bstr.start can be NULL when bstr.len is 0, so don't call memcmp or strncasecmp if that's the case. Passing NULL to string functions is invalid C, even when the length is 0, and it causes Windows to raise an invalid parameter error. Should fix #1155
This commit is contained in:
parent
ec7bc388d1
commit
476fc65b0f
|
@ -33,7 +33,9 @@
|
|||
|
||||
int bstrcmp(struct bstr str1, struct bstr str2)
|
||||
{
|
||||
int ret = memcmp(str1.start, str2.start, FFMIN(str1.len, str2.len));
|
||||
int ret = 0;
|
||||
if (str1.len && str2.len)
|
||||
ret = memcmp(str1.start, str2.start, FFMIN(str1.len, str2.len));
|
||||
|
||||
if (!ret) {
|
||||
if (str1.len == str2.len)
|
||||
|
@ -48,7 +50,9 @@ int bstrcmp(struct bstr str1, struct bstr str2)
|
|||
|
||||
int bstrcasecmp(struct bstr str1, struct bstr str2)
|
||||
{
|
||||
int ret = strncasecmp(str1.start, str2.start, FFMIN(str1.len, str2.len));
|
||||
int ret = 0;
|
||||
if (str1.len && str2.len)
|
||||
ret = strncasecmp(str1.start, str2.start, FFMIN(str1.len, str2.len));
|
||||
|
||||
if (!ret) {
|
||||
if (str1.len == str2.len)
|
||||
|
|
Loading…
Reference in New Issue