From patchwork Sun Nov 27 19:17:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 1578 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp1439397vsb; Sun, 27 Nov 2016 11:17:42 -0800 (PST) X-Received: by 10.28.131.72 with SMTP id f69mr15073241wmd.135.1480274262420; Sun, 27 Nov 2016 11:17:42 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ge18si51537731wjc.226.2016.11.27.11.17.41; Sun, 27 Nov 2016 11:17:42 -0800 (PST) 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=@overt.org; dkim=neutral (body hash did not verify) header.i=@overt.org; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CC6EA687EBB; Sun, 27 Nov 2016 21:17:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from so254-29.mailgun.net (so254-29.mailgun.net [198.61.254.29]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B52F2680461 for ; Sun, 27 Nov 2016 21:17:27 +0200 (EET) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=overt.org; q=dns/txt; s=k1; t=1480274251; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=hx5q/P6XCallr5YkVTS13U315xan+KmlFsLW54lOz94=; b=K+e+ITrHmDpBMwHGNXsqHK4o/wunvgRzMgY7TDYDcQsronoNaFyNkRPcqNyaonx8pJ+DQy3E tHiYqEVXXI9KdvDK/WydUECOG/Oh6jtSfSuKHqCeLIuik9HH0JEKwRFMcmWAxlzrdi2ze0YP xogsRhALFhbhzQh9Nc0WSXZQvvs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=overt.org; s=k1; q=dns; h=Sender: From: To: Cc: Subject: Date: Message-Id; b=GuN9zUEUNrnNM4ey5WBkAiaHrXJnYxQyrCZa0rxbQfJEsKZWPofik5Aw5PWdQLIkCi2k9n 1TgKvuAZh7dy49P5AFyAgN0TOSObWthbGPgImzu3QUyMBJzKQSq4gzoHH/mwPZK91Lb7vTuY dtbIehf8HSbvR8Mvbef5no64QlBYs= X-Mailgun-Sending-Ip: 198.61.254.29 X-Mailgun-Sid: WyIyM2Q3MCIsICJmZm1wZWctZGV2ZWxAZmZtcGVnLm9yZyIsICI0YTg5NjEiXQ== Received: from mail.overt.org (155.208.178.107.bc.googleusercontent.com [107.178.208.155]) by mxa.mailgun.org with ESMTP id 583b314b.7fc924cbaed8-smtp-out-n01; Sun, 27 Nov 2016 19:17:31 -0000 (UTC) Received: from authenticated-user (mail.overt.org [107.178.208.155]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id 24D98600B2; Sun, 27 Nov 2016 19:17:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1480274250; bh=XS+9y3S6AQKlubZaiJAyB7YgCZnMcoTmO3BdFxQU74s=; h=From:To:Cc:Subject:Date:From; b=qN564th79PaU2G2EFhBhcryUatuS3IJV72+cbCY9BioXmHZs5mM41SEM6XfxARsXs ZmerbVtAgrnD6+cT2EyCv9YcScf2F2qYwj7RmtiSHfkLSw9xXeFF+Dc8adHJN40jEC 2aB4CFzIbZwyj2OaCdeeJq+x/SyYStOI7Jpbt544Wd+8NjBek1MH5ft3iGrytN4f1y KMTvCL17bWp+m3PH7EBPqiuTO0ymDK3DVIxIxcikg8YgkRC8aPxvkyPskYYaGv3CPv gB0SCaDc0A2Lvo4HShanCIlCo4wCp86u4VwKGvyUSrgbGSoG7WLbFTdtSWVF303l8C PHmi2hlO7EaXQ== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Sun, 27 Nov 2016 11:17:26 -0800 Message-Id: <20161127191726.14893-1-philipl@overt.org> Subject: [FFmpeg-devel] [PATCH] tools/coverity: Add models for av_mallocz and av_free X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Philip Langdale MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This should deal with some false positives, but might lead to more of them depending on whether it realises that av_freep() wraps av_free() or not. Signed-off-by: Philip Langdale --- tools/coverity.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/tools/coverity.c b/tools/coverity.c index 80fc1c2..3cc248c 100644 --- a/tools/coverity.c +++ b/tools/coverity.c @@ -35,8 +35,30 @@ void *av_malloc(size_t size) { int has_memory; __coverity_negative_sink__(size); - if(has_memory) - return __coverity_alloc__(size); - else + if (has_memory) { + void *ptr = __coverity_alloc__(size); + __coverity_mark_as_uninitialized_buffer__(ptr); + __coverity_mark_as_afm_allocated__(ptr, "av_free"); + return ptr; + } else { return 0; + } +} + +void *av_mallocz(size_t size) { + int has_memory; + __coverity_negative_sink__(size); + if (has_memory) { + void *ptr = __coverity_alloc__(size); + __coverity_writeall0__(ptr); + __coverity_mark_as_afm_allocated__(ptr, "av_free"); + return ptr; + } else { + return 0; + } +} + +void *av_free(void *ptr) { + __coverity_free__(ptr); + __coverity_mark_as_afm_freed__(ptr, "av_free"); }