From: Ian Jackson Subject: Re: [PATCH RESEND] libxl: Avoid realloc(, 0) when libxl__xs_directory returns empty list Date: Tue, 12 Nov 2013 17:57:03 +0000 Message-ID: <21122.27631.608007.265161@mariner.uk.xensource.com> References: <516E0DCF.9090001@invisiblethingslab.com> <1366188196.8399.187.camel@zakaz.uk.xensource.com> <20848.6355.859738.100856@mariner.uk.xensource.com> <21122.25647.129932.90020@mariner.uk.xensource.com> <1384277485.10204.107.camel@kazak.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <1384277485.10204.107.camel@kazak.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell Cc: Roger Pau Monne , Marek Marczykowski , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org Ian Campbell writes ("Re: [PATCH RESEND] libxl: Avoid realloc(,0) when libx= l__xs_directory returns empty list"): > On Tue, 2013-11-12 at 17:23 +0000, Ian Jackson wrote: > > Ping. > = > I could have sworn this went in... Yes. I have found a bunch of these lying around in branches in my main tree. > > In three places in libxl this may result in a zero size argument being > > passed to malloc() or realloc(), which is not adviseable. > = > I thought it was strictly speaking fine, but I can see why it would be > best to avoid. Calling malloc(0) merely produces a fiddly-to-deal-with corner case, where it may succeed by returning 0. realloc(something,0) is actually wrong. If it returns 0 you don't know whether that means "I tried to allocate you a new 0-length block, but failed, so your original block is still there" or "I have successfully freed your old block; have this null pointer as an answer". > > Signed-off-by: Ian Jackson > > Acked-by: Roger Pau Monn=E9 > = > Acked-by: Ian Campbell Committed-by: Ian Jackson And put on the backport list. Thanks, Ian.