mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-02 11:06:31 +00:00
func_frame_drop: Handle allocation failure properly.
Handle allocation failure and simplify the allocation using asprintf. Resolves: #1366
This commit is contained in:
@@ -234,8 +234,10 @@ static int frame_drop_helper(struct ast_channel *chan, const char *cmd, char *da
|
||||
framedata->list_type = TX;
|
||||
}
|
||||
|
||||
buffer = ast_malloc(sizeof(value) + 3); /* leading and trailing comma and null terminator */
|
||||
snprintf(buffer, sizeof(value) + 2, ",%s,", value);
|
||||
if (ast_asprintf(&buffer, ",%s,", value) < 0) {
|
||||
ast_free(framedata);
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < ARRAY_LEN(frametype2str); i++) {
|
||||
if (strcasestr(buffer, frametype2str[i].str)) {
|
||||
framedata->values[i] = 1;
|
||||
|
Reference in New Issue
Block a user