From: Naveen Albert Date: Thu, 14 Aug 2025 14:00:09 +0000 (-0400) Subject: func_frame_drop: Handle allocation failure properly. X-Git-Tag: 22.6.0-rc1~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f2c9b84a36de90f83548a135fca73205a8dd3a48;p=thirdparty%2Fasterisk.git func_frame_drop: Handle allocation failure properly. Handle allocation failure and simplify the allocation using asprintf. Resolves: #1366 (cherry picked from commit fad87711231dec7a71e757f1993dbecec6a600c9) --- diff --git a/funcs/func_frame_drop.c b/funcs/func_frame_drop.c index 19694bc387..0d679ad9fc 100644 --- a/funcs/func_frame_drop.c +++ b/funcs/func_frame_drop.c @@ -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;