From: paco Date: Wed, 27 Jun 2018 13:50:04 +0000 (+0200) Subject: lib: untrusted argument (Coverity 1448386) X-Git-Tag: frr-6.1-dev~234^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=45ec351df2a5ffb5fcfbd6487bd8e98aa75efe84;p=matthieu%2Ffrr.git lib: untrusted argument (Coverity 1448386) Signed-off-by: F. Aragon --- diff --git a/lib/clippy.c b/lib/clippy.c index bcec6c2cca..44dcc02eb8 100644 --- a/lib/clippy.c +++ b/lib/clippy.c @@ -31,9 +31,11 @@ #define pychar wchar_t static wchar_t *wconv(const char *s) { - size_t outlen = mbstowcs(NULL, s, 0); + size_t outlen = s ? mbstowcs(NULL, s, 0) : 0; wchar_t *out = malloc((outlen + 1) * sizeof(wchar_t)); - mbstowcs(out, s, outlen + 1); + + if (outlen > 0) + mbstowcs(out, s, outlen); out[outlen] = 0; return out; }