From 9781a370023952383028e07399fd196a889bb2be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20B=C3=ADlka?= Date: Fri, 3 Apr 2015 15:46:29 +0200 Subject: Handle mblen return code when n is zero. --- wcsmbs/mbrtoc16.c | 3 +++ wcsmbs/mbrtowc.c | 3 +++ 2 files changed, 6 insertions(+) (limited to 'wcsmbs') diff --git a/wcsmbs/mbrtoc16.c b/wcsmbs/mbrtoc16.c index 542e5cf..f23b242 100644 --- a/wcsmbs/mbrtoc16.c +++ b/wcsmbs/mbrtoc16.c @@ -77,6 +77,9 @@ mbrtoc16 (char16_t *pc16, const char *s, size_t n, mbstate_t *ps) n = 1; } + if (n == 0) + return (size_t) -2; + /* Tell where we want the result. */ data.__outbuf = outbuf; data.__outbufend = outbuf + sizeof (wchar_t); diff --git a/wcsmbs/mbrtowc.c b/wcsmbs/mbrtowc.c index 49ca9c2..dbfe940 100644 --- a/wcsmbs/mbrtowc.c +++ b/wcsmbs/mbrtowc.c @@ -59,6 +59,9 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) n = 1; } + if (n == 0) + return (size_t) -2; + /* Tell where we want the result. */ data.__outbuf = outbuf; data.__outbufend = outbuf + sizeof (wchar_t); -- cgit v1.1