summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@users.noreply.github.com>2018-06-27 21:09:34 +0200
committerGitHub <noreply@github.com>2018-06-27 21:09:34 +0200
commit7f3ad069d7a9826dc609fb32af74ecca6b3f0571 (patch)
tree3b815b194120bd16e8f02303bc18112fb8098bf3 /lib
parentMerge pull request #2569 from pacovn/Coverity_1451361_Dereference_before_null... (diff)
parentlib: untrusted argument (Coverity 1448386) (diff)
downloadfrr-7f3ad069d7a9826dc609fb32af74ecca6b3f0571.tar.xz
frr-7f3ad069d7a9826dc609fb32af74ecca6b3f0571.zip
Merge pull request #2570 from pacovn/Coverity_1448386_Untrusted_value_as_argument
lib: untrusted argument (Coverity 1448386)
Diffstat (limited to 'lib')
-rw-r--r--lib/clippy.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/clippy.c b/lib/clippy.c
index bcec6c2cc..44dcc02eb 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;
}