From owner-svn-src-head@FreeBSD.ORG Fri Jun 20 19:42:33 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0F6C585A for ; Fri, 20 Jun 2014 19:42:33 +0000 (UTC) Received: from nm42-vm4.bullet.mail.bf1.yahoo.com (nm42-vm4.bullet.mail.bf1.yahoo.com [216.109.114.191]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A34532419 for ; Fri, 20 Jun 2014 19:42:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1403293018; bh=WkZtGNeb+Xkr2RKyBvt/84T2i+TNtYg5Kbq7hqBq+7E=; h=Received:Received:Received:X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:X-Rocket-Received:Message-ID:Date:From:Organization:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=ISJ6KLY4kitn+YKJcU0d8bof9PzRjQodsm9cX05Z53dOMn8QrBA7V+FaNqZrT1ug/exzTas+G2B+1oOoxBz6Mod5evHLJa4fHTX/wFVg3LYyr7JVyJLPm5Uv6vZGNX1yP3gRqFAEeFPHovuyYVAteOzoRdkZgjdLUBzaWi8fAIjLL5O4TsG5H/jG9vi4vvD0FsVpmqB0Fn5dLPnK0Wet4AA2/Q6JQN24KZyryy724swDa3LpxSsTPiJbP3hMGmOo0iT+6gEWb9hE6fg4Kj0txVoSugLka+Q7tEO1VrPf80X5YlW87Ty51pGaF3L+qdQThwHE5o4/1jgQjzUHrrCKpA== DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s2048; d=yahoo.com; b=V/2VkcAY/owj4D9rojCID/33yUrxfJoQmeP11UPVxvAvpDNYyVQXavq2z3OorlRjNqykTgN/j3C4xAphYt28SmSPesc8yW3c4spS4hW0suVEUTVTkvhEYBtqdkzhfSMwCEz3BdGGiKkESbtD5dTLfVrX02h5c0k2xJt+vT/x5l/f4It7dslv8tsCOO9aVYhcI3kjR5WQG6mTb/KvTJKk6tvWV/7Og8JaB2XeX/bEKtAUodQ3wbEhVV6OOJwZNK7vMsmV9wUsswZdNW5GU1iE0eHPXcjksccnBS3RqUGjLNu3KIwXn62I9QVf1kmp4T0yYmO3HRl67niSpIlPuHAsfA==; Received: from [98.139.215.140] by nm42.bullet.mail.bf1.yahoo.com with NNFMP; 20 Jun 2014 19:36:58 -0000 Received: from [98.139.211.206] by tm11.bullet.mail.bf1.yahoo.com with NNFMP; 20 Jun 2014 19:36:58 -0000 Received: from [127.0.0.1] by smtp215.mail.bf1.yahoo.com with NNFMP; 20 Jun 2014 19:36:58 -0000 X-Yahoo-Newman-Id: 598441.31858.bm@smtp215.mail.bf1.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: nb_D6UgVM1k0kYxrQlcjmnhXdguUZ4UeWFPozBXDjFOv7Lv PtXNFPLxDpC7lBm5Twmzzhu8sA1SbgR6C5zXl1wKDJcr4opU60n.wW_zcgSn iT7RWRBjx5A9ms_Qcs6ELTMG2b9qnthNa4bxeRJQk4PhL7NJykv0Lo6vKaXK BZAt54xm3XnCdG7gxWaEJkk6FFL1T3GebFn2dzo2XBCpje1ZtdA7.0ekg7Fz qa2hV.1tLZQgvAIgdbNOrp__iHIFGj_BD8dzpl9t_1p25lNgUVZjY6EH1jOf 1VL21t4gw7rdQ8R4mQJJ8IzhytDEl01t8cj_TcCNMH5iVPEUsF25k.YteZFU 6PCM_XApbraHTcLVBan6hs6D3qpys4EZvgJk.m_obE_0Mm_5iM1obQIUuPwl bw5en8WQ5gTdhNI5fic.ieDkR_ygAFCC6WqdsKzmVBrG7WrnBoRNqHx6jAp0 pTuSssyTYcPV04dC.EBzB9BD2VRVtcwn3tX81kMUYkoOvyyegBP.OBkwmNDU faV4LJnBYkBXc2Wqh2MejIYyzC0PsGFc3lVtF4yaW_jY1mQa46Z.5mkd9EFY Vm10bGAYRtVo7OPoAu9tNSb4Fs9yqARoc.Ic44IhJJL1IzS8r3UcZzyEmeR3 7gvRFKp4- X-Yahoo-SMTP: xcjD0guswBAZaPPIbxpWwLcp9Unf X-Rocket-Received: from [192.168.0.102] (pfg@190.157.126.109 with plain [98.138.105.21]) by smtp215.mail.bf1.yahoo.com with SMTP; 20 Jun 2014 12:36:58 -0700 PDT Message-ID: <53A48D62.4060801@FreeBSD.org> Date: Fri, 20 Jun 2014 14:37:06 -0500 From: Pedro Giffuni Organization: FreeBSD User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: Stefan Farfeleder Subject: Re: svn commit: r267675 - head/lib/libc/regex References: <201406201529.s5KFTAEB068038@svn.freebsd.org> <20140620182311.GA1214@mole.fafoe.narf.at> In-Reply-To: <20140620182311.GA1214@mole.fafoe.narf.at> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 20 Jun 2014 19:42:33 -0000 El 6/20/2014 1:23 PM, Stefan Farfeleder escribió: > 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. > OK ... I don't think there is any problem: If reallocf fails, newwides will be set to NULL and if free() is called it doesn't do anything when the argument is NULL. Also freeset() is meant to be called to "free a now-unused set" and it is not called within the library. I would think using a value when the allocation has failed is a much more serious issue than attempting to fail to free it after trying to use it. ;-). Pedro.