From: Vladimír Čunát Date: Mon, 29 Jan 2018 07:38:33 +0000 (+0100) Subject: fix two nitpicks from clang-scan X-Git-Tag: v2.0.0~9^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44c2ea6bb045b2c05b4f60ebb71d180ba0b8cf4c;p=thirdparty%2Fknot-resolver.git 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 --- 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)); } }