From 44c2ea6bb045b2c05b4f60ebb71d180ba0b8cf4c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Mon, 29 Jan 2018 08:38:33 +0100 Subject: [PATCH] fix two nitpicks from clang-scan - utils.c: overflowing size_t is basically impossible, but well... - stats.c: NULL would probably not cause a problem with zero length passed --- lib/utils.c | 5 ++++- modules/stats/stats.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/utils.c b/lib/utils.c index 5f61b10c8..eb0e77591 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -143,7 +143,10 @@ char* kr_strcatdup(unsigned n, ...) for (unsigned i = 0; i < n; ++i) { char *item = va_arg(vl, char *); const size_t new_len = total_len + strlen_safe(item); - if (unlikely(new_len < total_len)) return NULL; + if (unlikely(new_len < total_len)) { + va_end(vl); + return NULL; + } total_len = new_len; } va_end(vl); diff --git a/modules/stats/stats.c b/modules/stats/stats.c index cff04b24b..525175422 100644 --- a/modules/stats/stats.c +++ b/modules/stats/stats.c @@ -313,7 +313,7 @@ static char* stats_list(void *env, struct kr_module *module, const char *args) size_t args_len = args ? strlen(args) : 0; for (unsigned i = 0; i < metric_const_end; ++i) { struct const_metric_elm *elm = &const_metrics[i]; - if (strncmp(elm->key, args, args_len) == 0) { + if (args && strncmp(elm->key, args, args_len) == 0) { json_append_member(root, elm->key, json_mknumber(elm->val)); } } -- 2.47.2