mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-18 18:58:22 +00:00
various files - fix some alerts raised by lgtm code analysis
This patch fixes several issues reported by the lgtm code analysis tool: https://lgtm.com/projects/g/asterisk/asterisk Not all reported issues were addressed in this patch. This patch mostly fixes confirmed reported errors, potential problematic code points, and a few other "low hanging" warnings or recommendations found in core supported modules. These include, but are not limited to the following: * innapropriate stack allocation in loops * buffer overflows * variable declaration "hiding" another variable declaration * comparisons results that are always the same * ambiguously signed bit-field members * missing header guards Change-Id: Id4a881686605d26c94ab5409bc70fcc21efacc25
This commit is contained in:
committed by
George Joseph
parent
990a91b44a
commit
bdd785d31c
17
main/event.c
17
main/event.c
@@ -419,7 +419,7 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...)
|
||||
ie_type != AST_EVENT_IE_END;
|
||||
ie_type = va_arg(ap, enum ast_event_ie_type))
|
||||
{
|
||||
struct ast_event_ie_val *ie_value = ast_alloca(sizeof(*ie_value));
|
||||
struct ast_event_ie_val *ie_value = ast_malloc(sizeof(*ie_value));
|
||||
int insert = 0;
|
||||
|
||||
memset(ie_value, 0, sizeof(*ie_value));
|
||||
@@ -443,7 +443,7 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...)
|
||||
{
|
||||
void *data = va_arg(ap, void *);
|
||||
size_t datalen = va_arg(ap, size_t);
|
||||
ie_value->payload.raw = ast_alloca(datalen);
|
||||
ie_value->payload.raw = ast_malloc(datalen);
|
||||
memcpy(ie_value->payload.raw, data, datalen);
|
||||
ie_value->raw_datalen = datalen;
|
||||
insert = 1;
|
||||
@@ -491,7 +491,7 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...)
|
||||
|
||||
/* realloc inside one of the append functions failed */
|
||||
if (!event) {
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -501,6 +501,17 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...)
|
||||
ast_event_append_eid(&event);
|
||||
}
|
||||
|
||||
cleanup:
|
||||
AST_LIST_TRAVERSE_SAFE_BEGIN(&ie_vals, ie_val, entry) {
|
||||
AST_LIST_REMOVE_CURRENT(entry);
|
||||
|
||||
if (ie_val->ie_pltype == AST_EVENT_IE_PLTYPE_RAW) {
|
||||
ast_free(ie_val->payload.raw);
|
||||
}
|
||||
ast_free(ie_val);
|
||||
}
|
||||
AST_LIST_TRAVERSE_SAFE_END;
|
||||
|
||||
return event;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user