diff options
author | Quentin Young <qlyoung@users.noreply.github.com> | 2018-06-27 21:09:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-27 21:09:34 +0200 |
commit | 7f3ad069d7a9826dc609fb32af74ecca6b3f0571 (patch) | |
tree | 3b815b194120bd16e8f02303bc18112fb8098bf3 /lib | |
parent | Merge pull request #2569 from pacovn/Coverity_1451361_Dereference_before_null... (diff) | |
parent | lib: untrusted argument (Coverity 1448386) (diff) | |
download | frr-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.c | 6 |
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; } |