]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
func_frame_drop: Handle allocation failure properly.
authorNaveen Albert <asterisk@phreaknet.org>
Thu, 14 Aug 2025 14:00:09 +0000 (10:00 -0400)
committerNaveen Albert <asterisk@phreaknet.org>
Fri, 15 Aug 2025 16:09:21 +0000 (16:09 +0000)
Handle allocation failure and simplify the allocation using asprintf.

Resolves: #1366

funcs/func_frame_drop.c

index 19694bc387780a94515521881b4d407d1eddcd95..0d679ad9fca606945e1ea2adb08b5700522f578f 100644 (file)
@@ -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;