lib: untrusted argument (Coverity 1448386)

Signed-off-by: F. Aragon <paco@voltanet.io>
This commit is contained in:
paco 2018-06-27 15:50:04 +02:00
parent 71a7b1f82f
commit 45ec351df2
No known key found for this signature in database
GPG Key ID: FD112A8C7E6A5E4A

View File

@ -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;
}