From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NFSIT-0006uU-Jp for qemu-devel@nongnu.org; Tue, 01 Dec 2009 07:57:37 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NFSIO-0006tL-4G for qemu-devel@nongnu.org; Tue, 01 Dec 2009 07:57:36 -0500 Received: from [199.232.76.173] (port=50931 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NFSIN-0006tI-Vz for qemu-devel@nongnu.org; Tue, 01 Dec 2009 07:57:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52606) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NFSIN-0005GI-NY for qemu-devel@nongnu.org; Tue, 01 Dec 2009 07:57:31 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nB1CvUIn013066 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 1 Dec 2009 07:57:30 -0500 Message-ID: <4B1512B8.4020700@redhat.com> Date: Tue, 01 Dec 2009 13:57:28 +0100 From: Gerd Hoffmann MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH] Permit zero-sized qemu_malloc() & friends References: <4B150EAD.4050502@redhat.com> In-Reply-To: <4B150EAD.4050502@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org On 12/01/09 13:40, Gerd Hoffmann wrote: >> + return oom_check(malloc(size ? size : 1)); >> void *qemu_realloc(void *ptr, size_t size) >> { >> + return oom_check(realloc(ptr, size ? size : 1)); > > qemu_realloc(qemu_malloc(0), 42); > > should better work correctly ... Oops, scratch that. "return malloc(size ? size : 1)" is very different from "return size ? malloc(size) : 1" which my mind somehow made out of the code line above ... sorry, Gerd