From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T2RJT-0001Mx-Ve for qemu-devel@nongnu.org; Fri, 17 Aug 2012 14:30:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T2RJT-0001n0-2e for qemu-devel@nongnu.org; Fri, 17 Aug 2012 14:30:27 -0400 Received: from mx.meyering.net ([88.168.87.75]:45159) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T2RJS-0001mq-Rk for qemu-devel@nongnu.org; Fri, 17 Aug 2012 14:30:26 -0400 From: Jim Meyering In-Reply-To: <502E6B68.6030807@suse.de> ("Andreas \=\?iso-8859-1\?Q\?F\=E4rber\?\= \=\?iso-8859-1\?Q\?\=22's\?\= message of "Fri, 17 Aug 2012 18:03:52 +0200") References: <1337681798-22395-1-git-send-email-jim@meyering.net> <1337681798-22395-3-git-send-email-jim@meyering.net> <502E6B68.6030807@suse.de> Date: Fri, 17 Aug 2012 20:30:26 +0200 Message-ID: <87d32p2wxp.fsf@rho.meyering.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCHv3 2/2] envlist.c: handle strdup failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?iso-8859-1?Q?F=E4rber?= Cc: qemu-devel@nongnu.org Andreas F=E4rber wrote: > Am 22.05.2012 12:16, schrieb Jim Meyering: >> From: Jim Meyering >> >> Without this, envlist_to_environ may silently fail to copy all >> strings into the destination buffer, and both callers would leak >> any env strings allocated after a failing strdup, because the >> freeing code stops at the first NULL pointer. >> >> Signed-off-by: Jim Meyering >> --- >> envlist.c | 12 ++++++++++-- >> 1 file changed, 10 insertions(+), 2 deletions(-) >> >> diff --git a/envlist.c b/envlist.c >> index e44889b..df5c723 100644 >> --- a/envlist.c >> +++ b/envlist.c >> @@ -234,8 +234,16 @@ envlist_to_environ(const envlist_t *envlist, size_t= *count) >> return (NULL); >> >> for (entry =3D envlist->el_entries.lh_first; entry !=3D NULL; >> - entry =3D entry->ev_link.le_next) { >> - *(penv++) =3D strdup(entry->ev_var); >> + entry =3D entry->ev_link.le_next, penv++) { > > Scratch my comment on 1/2, there's an added penv++ that I overlooked. > Not changing the indentation twice would still be nice. I posted a V4 that does that, and removes parens around return arguments as well. However, I did not remove assignments from conditionals. IMHO, that would require an inordinate amount of change for the marginal gain of making legacy code conform.