From patchwork Wed May 8 13:35:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve Dickson X-Patchwork-Id: 10935691 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 489E6912 for ; Wed, 8 May 2019 13:35:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3951826253 for ; Wed, 8 May 2019 13:35:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DA162842E; Wed, 8 May 2019 13:35:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC96326253 for ; Wed, 8 May 2019 13:35:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727270AbfEHNfo (ORCPT ); Wed, 8 May 2019 09:35:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:53868 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727242AbfEHNfn (ORCPT ); Wed, 8 May 2019 09:35:43 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E9DA13079B90 for ; Wed, 8 May 2019 13:35:42 +0000 (UTC) Received: from madhat.boston.devel.redhat.com (ovpn-116-59.phx2.redhat.com [10.3.116.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id A33415C640 for ; Wed, 8 May 2019 13:35:42 +0000 (UTC) From: Steve Dickson To: Linux NFS Mailing list Subject: [PATCH 06/19] Removed bad frees from nfs/xcommon.c Date: Wed, 8 May 2019 09:35:23 -0400 Message-Id: <20190508133536.6077-7-steved@redhat.com> In-Reply-To: <20190508133536.6077-1-steved@redhat.com> References: <20190508133536.6077-1-steved@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 08 May 2019 13:35:42 +0000 (UTC) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP nfs/xcommon.c:63: incorrect_free: "free" frees incorrect pointer "(void *)s". nfs/xcommon.c:81: incorrect_free: "free" frees incorrect pointer "(void *)s". Signed-off-by: Steve Dickson --- support/nfs/xcommon.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/support/nfs/xcommon.c b/support/nfs/xcommon.c index 14e580e..3989f0b 100644 --- a/support/nfs/xcommon.c +++ b/support/nfs/xcommon.c @@ -53,14 +53,17 @@ char * xstrconcat3 (const char *s, const char *t, const char *u) { char *res; - if (!s) s = ""; + int dofree = 1; + + if (!s) s = "", dofree=0; if (!t) t = ""; if (!u) u = ""; res = xmalloc(strlen(s) + strlen(t) + strlen(u) + 1); strcpy(res, s); strcat(res, t); strcat(res, u); - free((void *) s); + if (dofree) + free((void *) s); return res; } @@ -69,7 +72,9 @@ char * xstrconcat4 (const char *s, const char *t, const char *u, const char *v) { char *res; - if (!s) s = ""; + int dofree = 1; + + if (!s) s = "", dofree=0; if (!t) t = ""; if (!u) u = ""; if (!v) v = ""; @@ -78,7 +83,8 @@ xstrconcat4 (const char *s, const char *t, const char *u, const char *v) { strcat(res, t); strcat(res, u); strcat(res, v); - free((void *) s); + if (dofree) + free((void *) s); return res; }