diff --git a/.clang-tidy b/.clang-tidy index bbc7152ee4..059050644c 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -16,9 +16,9 @@ Checks: '* ,-clang-analyzer-optin.performance.Padding ,-clang-analyzer-security.FloatLoopCounter ,-clang-analyzer-security.insecureAPI.strcpy - ,-clang-analyzer-unix.API ,-clang-analyzer-unix.cstring.BadSizeArg ,-clang-analyzer-unix.Malloc + ,-clang-analyzer-unix.MallocSizeof ,-cppcoreguidelines-c-copy-assignment-signature ,-cppcoreguidelines-interfaces-global-init ,-cppcoreguidelines-no-malloc @@ -59,6 +59,7 @@ Checks: '* ,-modernize-use-equals-delete ,-modernize-use-override ,-modernize-use-using + ,-performance-inefficient-string-concatenation ,-readability-avoid-const-params-in-decls ,-readability-else-after-return ,-readability-implicit-bool-cast @@ -66,8 +67,6 @@ Checks: '* ,-readability-named-parameter ,-readability-non-const-parameter ,-readability-redundant-declaration - ,-performance-inefficient-string-concatenation - ,-clang-analyzer-unix.MallocSizeof ,-readability-redundant-member-init ,-readability-simplify-boolean-expr ' @@ -86,4 +85,4 @@ CheckOptions: - key: readability-function-size.LineThreshold value: '4000' - key: readability-function-size.StatementThreshold - value: '4000' \ No newline at end of file + value: '4000' diff --git a/src/modules/systemlib/param/param.c b/src/modules/systemlib/param/param.c index f4d00e40a1..3403d3aedc 100644 --- a/src/modules/systemlib/param/param.c +++ b/src/modules/systemlib/param/param.c @@ -727,7 +727,14 @@ param_set_internal(param_t param, const void *val, bool mark_saved, bool notify_ case PARAM_TYPE_STRUCT ... PARAM_TYPE_STRUCT_MAX: if (s->val.p == NULL) { - s->val.p = malloc(param_size(param)); + size_t psize = param_size(param); + + if (psize > 0) { + s->val.p = malloc(psize); + + } else { + s->val.p = NULL; + } if (s->val.p == NULL) { debug("failed to allocate parameter storage"); @@ -1168,7 +1175,14 @@ param_import_callback(bson_decoder_t decoder, void *private, bson_node_t node) } /* XXX check actual file data size? */ - tmp = malloc(param_size(param)); + size_t psize = param_size(param); + + if (psize > 0) { + tmp = malloc(psize); + + } else { + tmp = NULL; + } if (tmp == NULL) { debug("failed allocating for '%s'", node->name);