From patchwork Wed Feb 24 21:13:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 62834 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp2643709lbl; Wed, 24 Feb 2016 13:14:09 -0800 (PST) X-Received: by 10.66.154.233 with SMTP id vr9mr57983795pab.66.1456348447277; Wed, 24 Feb 2016 13:14:07 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id qk3si7247190pac.28.2016.02.24.13.14.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Feb 2016 13:14:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 91A6C1A1F60; Wed, 24 Feb 2016 13:14:10 -0800 (PST) X-Original-To: edk2-devel@ml01.01.org Delivered-To: edk2-devel@ml01.01.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id A50EE1A1F60 for ; Wed, 24 Feb 2016 13:14:08 -0800 (PST) Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 77916821C3; Wed, 24 Feb 2016 21:14:04 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-22.phx2.redhat.com [10.3.113.22]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1OLDt1b026826; Wed, 24 Feb 2016 16:14:03 -0500 From: Laszlo Ersek To: edk2-devel-01 Date: Wed, 24 Feb 2016 22:13:51 +0100 Message-Id: <1456348432-18818-4-git-send-email-lersek@redhat.com> In-Reply-To: <1456348432-18818-1-git-send-email-lersek@redhat.com> References: <1456348432-18818-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Cc: Ting Ye , David Woodhouse , Qin Long Subject: [edk2] [PATCH 3/4] CryptoPkg: RuntimeCryptLib: support realloc(NULL, size) X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The ISO C standard says about realloc(), If ptr is a null pointer, the realloc function behaves like the malloc function for the specified size. The realloc() implementation doesn't conform to this currently, so add a check and call malloc() if appropriate. Cc: David Woodhouse Cc: Qin Long Cc: Ting Ye Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c | 4 ++++ 1 file changed, 4 insertions(+) -- 1.8.3.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c b/CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c index 45ef9ff5f252..413e47e92325 100644 --- a/CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c +++ b/CryptoPkg/Library/BaseCryptLib/SysCall/RuntimeMemAllocation.c @@ -396,6 +396,10 @@ void *realloc (void *ptr, size_t size) UINTN StartPageIndex; UINTN PageCount; + if (ptr == NULL) { + return malloc (size); + } + // // Get Original Size of ptr //