From: Ian Jackson Subject: Re: [PATCH 08/13 v4] libxl: don't leak ptr in libxl_list_vm error case Date: Mon, 2 Dec 2013 15:03:56 +0000 Message-ID: <21148.41308.706376.518540@mariner.uk.xensource.com> References: <1385982328-21666-1-git-send-email-mattd@bugfuzz.com> <21148.30769.626843.394382@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Matthew Daley Cc: Andrew Cooper , Stefano Stabellini , Ian Campbell , Xen-devel List-Id: xen-devel@lists.xenproject.org Matthew Daley writes ("Re: [PATCH 08/13 v4] libxl: don't leak ptr in libxl_list_vm error case"): > On Tue, Dec 3, 2013 at 1:08 AM, Ian Jackson wrote: > >> + ptr = calloc(ret ? ret : 1, sizeof(libxl_vminfo)); > > > > I think this should be a call to libxl__calloc, which cannot fail. > > That adds the returned pointer to the GC, and since libxl_list_vm is > part of the public libxl interface, I don't think that would be an > acceptable change? That's what NOGC is for. You pass it to libxl__calloc et al, instead of gc. > > You still need to prat about with the ?: though I'm afraid. > > You mean, you require the use of "a ?: b" over "a ? a : b"? I mean only that libxl__calloc has the same unfortunate semantics as calloc, when the size is zero, so you need to keep your existing ? :. I agree that use of "a ?: b" in this case is a bad thing so please don't change that. Thanks, Ian.