From 45ec351df2a5ffb5fcfbd6487bd8e98aa75efe84 Mon Sep 17 00:00:00 2001 From: paco Date: Wed, 27 Jun 2018 15:50:04 +0200 Subject: [PATCH] lib: untrusted argument (Coverity 1448386) Signed-off-by: F. Aragon --- lib/clippy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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; } -- 2.39.5