forked from Archive/PX4-Autopilot
clang-tidy param avoid malloc(0)
This commit is contained in:
parent
2e0ed3b47b
commit
768faa1ae3
|
@ -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'
|
||||
value: '4000'
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue