Check the returned value of memchr(3) before using it

Reported by:	Coverity
CID:		1338530
This commit is contained in:
Baptiste Daroussin 2016-04-20 20:44:30 +00:00
parent 4dd13092b5
commit d3591d68a9

View File

@ -133,11 +133,14 @@ _ascii_mbsnrtowcs(wchar_t * __restrict dst, const char ** __restrict src,
if (dst == NULL) {
s = memchr(*src, '\0', nms);
if (s == NULL)
return (nms);
if (*s & 0x80) {
errno = EILSEQ;
return ((size_t)-1);
}
return (s != NULL ? s - *src : nms);
return (s - *src);
}
s = *src;