This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 1/2] openpty: close slave pty fd on error
- From: Florian Weimer <fweimer at redhat dot com>
- To: Christian Brauner <christian dot brauner at ubuntu dot com>, libc-alpha at sourceware dot org, stgraber at stgraber dot org, serge at hallyn dot com
- Date: Tue, 29 Aug 2017 11:02:03 +0200
- Subject: Re: [PATCH 1/2] openpty: close slave pty fd on error
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=fweimer at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 86797552DB
- References: <20170826134449.26527-1-christian.brauner@ubuntu.com>
On 08/26/2017 03:44 PM, Christian Brauner wrote:
> fail:
> close (master);
> + if (slave != -1)
> + close(slave);
> return -1;
This is inconsistent with how the code frees buf if there is an error:
For buf, the free operation happens before the fail tail. I think we
should keep this consistent: either free exactly what is needed, or have
a single function exit which checks for initialization and frees what
has been allocated.
Thanks,
Florian