]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
fix two nitpicks from clang-scan
authorVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 29 Jan 2018 07:38:33 +0000 (08:38 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 29 Jan 2018 07:53:14 +0000 (08:53 +0100)
- 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
modules/stats/stats.c

index 5f61b10c87fb1ce9d8a89360e15dcb3f65a8c355..eb0e77591efd5400980c7e1de1ab607a09ee98dd 100644 (file)
@@ -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);
index cff04b24b00c08c16d494f85fecbed370460b3ca..525175422034b9e10c21875eeeaa887c4bd62c15 100644 (file)
@@ -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));
                }
        }