summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpaco <paco@voltanet.io>2018-06-27 15:50:04 +0200
committerpaco <paco@voltanet.io>2018-06-27 15:50:04 +0200
commit45ec351df2a5ffb5fcfbd6487bd8e98aa75efe84 (patch)
tree9072d50def272075851c8133098eeeaac6bc8d5b
parentMerge pull request #2556 from pacovn/Coverity_1465491_Untrusted_value_as_argu... (diff)
downloadfrr-45ec351df2a5ffb5fcfbd6487bd8e98aa75efe84.tar.xz
frr-45ec351df2a5ffb5fcfbd6487bd8e98aa75efe84.zip
lib: untrusted argument (Coverity 1448386)
Signed-off-by: F. Aragon <paco@voltanet.io>
-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;
}