From owner-svn-src-all@FreeBSD.ORG Fri Jun 20 18:23:24 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BFBB9EDC; Fri, 20 Jun 2014 18:23:24 +0000 (UTC) Received: from fep33.mx.upcmail.net (fep33.mx.upcmail.net [62.179.121.51]) by mx1.freebsd.org (Postfix) with ESMTP id 81BD62CF6; Fri, 20 Jun 2014 18:23:22 +0000 (UTC) Received: from edge04.upcmail.net ([192.168.13.239]) by viefep33-int.chello.at (InterMail vM.8.01.05.05 201-2260-151-110-20120111) with ESMTP id <20140620182315.HLRZ1788.viefep33-int.chello.at@edge04.upcmail.net>; Fri, 20 Jun 2014 20:23:15 +0200 Received: from mole.fafoe.narf.at ([80.109.55.137]) by edge04.upcmail.net with edge id GiPF1o00J2xdvHc03iPFHL; Fri, 20 Jun 2014 20:23:15 +0200 X-SourceIP: 80.109.55.137 Received: by mole.fafoe.narf.at (Postfix, from userid 1001) id E35906D47C; Fri, 20 Jun 2014 20:23:11 +0200 (CEST) Date: Fri, 20 Jun 2014 20:23:11 +0200 From: Stefan Farfeleder To: "Pedro F. Giffuni" Subject: Re: svn commit: r267675 - head/lib/libc/regex Message-ID: <20140620182311.GA1214@mole.fafoe.narf.at> References: <201406201529.s5KFTAEB068038@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201406201529.s5KFTAEB068038@svn.freebsd.org> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jun 2014 18:23:24 -0000 On Fri, Jun 20, 2014 at 03:29:10PM +0000, Pedro F. Giffuni wrote: > Author: pfg > Date: Fri Jun 20 15:29:09 2014 > New Revision: 267675 > URL: http://svnweb.freebsd.org/changeset/base/267675 > > Log: > regex: Make use of reallocf(). > > Use of reallocf is useful in libraries as we are not certain the > application will exit after NULL. > > This somewhat reduces portability but if since you are building > this as part of libc it is likely you have our non-standard > reallocf(3) already. > > Reviewed by: ache > MFC after: 5 days > > Modified: > head/lib/libc/regex/regcomp.c > > Modified: head/lib/libc/regex/regcomp.c > ============================================================================== > --- head/lib/libc/regex/regcomp.c Fri Jun 20 13:26:49 2014 (r267674) > +++ head/lib/libc/regex/regcomp.c Fri Jun 20 15:29:09 2014 (r267675) > @@ -1111,7 +1111,7 @@ allocset(struct parse *p) > { > cset *cs, *ncs; > > - ncs = realloc(p->g->sets, (p->g->ncsets + 1) * sizeof(*ncs)); > + ncs = reallocf(p->g->sets, (p->g->ncsets + 1) * sizeof(*ncs)); > if (ncs == NULL) { > SETERROR(REG_ESPACE); > return (NULL); > @@ -1174,7 +1174,7 @@ CHadd(struct parse *p, cset *cs, wint_t > if (ch < NC) > cs->bmp[ch >> 3] |= 1 << (ch & 7); > else { > - newwides = realloc(cs->wides, (cs->nwides + 1) * > + newwides = reallocf(cs->wides, (cs->nwides + 1) * > sizeof(*cs->wides)); > if (newwides == NULL) { > SETERROR(REG_ESPACE); Hi Pedro, I don't think these changes are OK. If reallocf() fails here, the cs->wides pointer will be freed and later freeset() will call free(cs->wides), probably crashing. The other cases are most probably similar though I haven't examined them closely. BR, Stefan