From patchwork Thu Jul 22 07:05:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 29005 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a5d:965a:0:0:0:0:0 with SMTP id d26csp278850ios; Thu, 22 Jul 2021 00:05:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKjWjYWVro7+JQTOg9R9Tyjw6I2dL0Slok+agammybGUro6pM65eHwV2DfDwrdCnkndUNP X-Received: by 2002:a17:906:2cc5:: with SMTP id r5mr41564427ejr.454.1626937525080; Thu, 22 Jul 2021 00:05:25 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ee38si8666742edb.225.2021.07.22.00.05.24; Thu, 22 Jul 2021 00:05:25 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@outlook.com header.s=selector1 header.b=l+V0etoT; arc=fail (body hash mismatch); spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7869868A756; Thu, 22 Jul 2021 10:05:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DB5-obe.outbound.protection.outlook.com (mail-oln040092071105.outbound.protection.outlook.com [40.92.71.105]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6EBAF68A56F for ; Thu, 22 Jul 2021 10:05:14 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vyfga1Ws0JprBmm25zaQgvPki25OeONHU9yzDMdtLtN3Qzfiy1OXmxj+NaDeK73gyTyewFGDrIobvlncvYdvzqtfTj+d+x+MioRTnjwmJ3f0tRgj8A38Jn6Wf8oiI923OzXslwvSkcMfahJrJVWUWTuEKXYxJG+bPhdJ6cqWmbIRzdEcOTTVz/PgJsPfuWexKX2ATKTGE4EYfBzYwp/Falc9wyVwr58xNsMvOUv8iuu7x8BY4nq9KkRsHk1BkX34xdDJsrnCZ1DvsfDwk9GZm88FM5UAkK5Y2Vw6p4rbHorQ2dv/DsP5GYXlZsurjnQQN3xuAVRBuF/16IlCC3x1sQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SnCar5lt3ZQp6w76e97MNvRh6FshpdYxT/aLPr2/u14=; b=Td+TQih+gFMXZBvgP86iw7pv743LqsAiItj+pqIfSVpa7mlkjLA6gAETnOJnVyGQnuUsYkRvxKeteSBv738DCvW4rPQpKTGUW5r1WmIKb78UFpxaKHw7+T4jDC1EJ9EACHFeWQ6ELMexg0Pk9Ur/Y7UV7ncIUvIS/DshC0zxG3Tfxcm0EDHS+8ZHV/9ThtOgyA0/FIBulacCK1Uxz+v/jQquCKJYSI4Dt0xs/qP/MMrJoq5koVH/dmjaq9ZZ9RKbU/xalTMxqf5w5al7wFJ4JNNirDttZy8CojOEMRCKaFXMK7OnnY50MmW1gJOYrvG1mAY837GcFjbkPaacKXke6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SnCar5lt3ZQp6w76e97MNvRh6FshpdYxT/aLPr2/u14=; b=l+V0etoTWcFDPNsStm6AcqHD6WBqB+B3RzFULemMTjcre8nE+k707cObA4/96H9CWYzXGwTcvRhtalszch7BvfIvauBQO/2j3BzDAWsuzDS4Vut9qCy1ZwqK28R6pO6h0hVa9f9gOam0f9Pn2WnRxD7NOh+mXoDVK4/OjRA9iVRkQDdjQpYMer4o3FPFU3iu66k3NckVffI6JPPPNCA9PQk320IlPBNftsSy7I88ucK4z93Yndw8GbfBwzPV8WT/N216XeGasRnnLjpYxqyQ8tRr0g23CwPcU9K6JSouVpo20K8dbuYBP1O21HFJu0enCDuvVRQOlBzGmV4qjgSZ9A== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AM6PR03MB4822.eurprd03.prod.outlook.com (2603:10a6:20b:81::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.23; Thu, 22 Jul 2021 07:05:12 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::c9b2:14f8:d555:6f2d%7]) with mapi id 15.20.4331.034; Thu, 22 Jul 2021 07:05:12 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 22 Jul 2021 09:05:04 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 X-TMN: [rLjRIkoJcB9myayjzpekbyhrgOb9+g2q] X-ClientProxiedBy: AM0PR10CA0118.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:e6::35) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210722070504.315551-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.94.230) by AM0PR10CA0118.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:e6::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25 via Frontend Transport; Thu, 22 Jul 2021 07:05:12 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e00c3497-0cb3-46b7-d760-08d94cdf0c8d X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEuuWyilVKMxEe3LXCNWWggI3GC8rrs7FbNjw/VUG5ysqaLoLaCyUhJbEPHT//2cACq79B84g9MsfgZjp8ZaMowWKa00JFVlIsu1CdFQSyAYBnatuL9egnfp3Daw1TOWBox8ghxqbEh3Rs+BR4FUcyqPsrvSgDAxv/07AkKh3cROdiTOz6rdQ+ur77TG0QGN5T8OiC+dNjYEdkz2d5m+aZnST+3B5MUFLB++FwJ4PH9D1pARPKQjP6PgQanvniIgqL877YjA7Y6ZX+0I8buH05QLD+kwFHf+ODq9b4zoYne5IIheCAAkPa0jJy6P/lCkYtRzMpjm3laPHik1kBuGPvfMxkqlYj1xFMiOGtnrH/AV7ozKJXKm76Ft8QtK0y+XQG21sGd0AWsZkrCnr1rci74tUrtDca6Sg4sxLCvYbjY5DnbVeHBARMxxjoGGP7ztye8+H0nZ7cyosuMlpS5d4DTGNq+V9qWANuhHtMdzRy7Uhsa6RFPPFrx8/V5BTTWnjnqITkIM9qseEUvqh7PQsbb0tWzWtbcO79D8wr8SwqgLZhGNJ5umb5IxaQ7URE/wFydOJnQ5os/KgaQmO9hUwk3OKSolL4QrrtFXCJnVIjYGRDii6qZPXtorn7gIdoc9K5M4eF1KPCb9D08sXr/H8QfE5Y3kJLHRoxHYVXdOumHokxGVUnF3E/7O64LjF/3p9+L4d8Y0unDrMTYIhdCNWmG8izfl+ZwWuIGkdF3bctMMN2MOGwiq+tsxpyhOKSgsWdoxbq5XnqiAm0WKiMv3xWtv X-MS-TrafficTypeDiagnostic: AM6PR03MB4822: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fWe9etaD0V6e/mfu3gK5g23Cj2y+kCC1tofi15UF41ocrHtUGvGLglrVdOcvGJcldHM1FLqDbTbESnR5HnRbfpkx3vH0IYeoJgX1HSI1X1gZq+3CytBTu3ywWopkbtaKZH08uYySwzw91XD7N1zvUt71X6Aa+C/361S9zjnsEgPtQygy4eo6KORgKL0i43QWkmquZbdvGqoNz3D0+JurTHGUZ1iyV527OWmC7e0KUvZd2YlcCCka4lnTa8LBJvfo8yszQV6SnQGh/Oqp/uYc8zIfbImC5ntXonNosTEX3ToTjR99koxaep5n1Y5s1j5YfPZQOi1bE7L/GnYtQWNiymkwCMMKfSy/W4rQ3x7jqnXf8DXod3+Atarqn8VbyRidHHMEgZheSP9xXqiav/fbd3J2k5jbTCqcoywG85SjzcoT8nBolB4tbEEVPTtZGbwq X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XhSGRHRcT55JZBhE3sAp1Y4QdaDtbXAyy2KPi0sElZ9zi+P+h1nv590fzh2+ddJMvnOoKN+4HRR+zrWnjQzx4FwpzHentZRISXb/4P7jjJyqHUEhi4kUWh8bp6rXhgbbWpgMYH83+G+wZCHK4AOfwA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e00c3497-0cb3-46b7-d760-08d94cdf0c8d X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2021 07:05:12.6216 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB4822 Subject: [FFmpeg-devel] [PATCH] tools/graph2dot: Don't use sizeof(AVFilterGraph), check allocation X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +clMfb4UX6X3 Use avfilter_graph_alloc() instead of av_mallocz(sizeof(AVFilterGraph)) to allocate an AVFilterGraph; this also properly allocates the graph's internal. The current code just happened to work because it did not make any use of said internal. Also check the allocation; this fixes Coverity #1292528. Signed-off-by: Andreas Rheinhardt --- tools/graph2dot.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/graph2dot.c b/tools/graph2dot.c index d5c1e4e3c7..fe1eedb9f3 100644 --- a/tools/graph2dot.c +++ b/tools/graph2dot.c @@ -113,7 +113,7 @@ int main(int argc, char **argv) FILE *outfile = NULL; FILE *infile = NULL; char *graph_string = NULL; - AVFilterGraph *graph = av_mallocz(sizeof(AVFilterGraph)); + AVFilterGraph *graph; char c; av_log_set_level(AV_LOG_DEBUG); @@ -189,6 +189,12 @@ int main(int argc, char **argv) *p = '\0'; } + graph = avfilter_graph_alloc(); + if (!graph) { + fprintf(stderr, "Memory allocation failure\n"); + return 1; + } + if (avfilter_graph_parse(graph, graph_string, NULL, NULL, NULL) < 0) { fprintf(stderr, "Failed to parse the graph description\n"); return 1;