From owner-svn-src-all@freebsd.org Fri May 25 15:11:35 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C3996EEA4A4; Fri, 25 May 2018 15:11:35 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: from spindle.one-eyed-alien.net (spindle.one-eyed-alien.net [199.48.129.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6F36584D01; Fri, 25 May 2018 15:11:35 +0000 (UTC) (envelope-from brooks@spindle.one-eyed-alien.net) Received: by spindle.one-eyed-alien.net (Postfix, from userid 3001) id 921C25A9F12; Fri, 25 May 2018 15:11:34 +0000 (UTC) Date: Fri, 25 May 2018 15:11:34 +0000 From: Brooks Davis To: Marcelo Araujo Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r334199 - head/usr.sbin/bhyve Message-ID: <20180525151134.GB99063@spindle.one-eyed-alien.net> References: <201805250207.w4P275Pf060725@repo.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="PmA2V3Z32TCmWXqI" Content-Disposition: inline In-Reply-To: <201805250207.w4P275Pf060725@repo.freebsd.org> User-Agent: Mutt/1.9.4 (2018-02-28) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.26 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, 25 May 2018 15:11:35 -0000 --PmA2V3Z32TCmWXqI Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 25, 2018 at 02:07:05AM +0000, Marcelo Araujo wrote: > Author: araujo > Date: Fri May 25 02:07:05 2018 > New Revision: 334199 > URL: https://svnweb.freebsd.org/changeset/base/334199 >=20 > Log: > Fix a memory leak on topology_parse(). > =20 > strdup(3) allocates memory for a copy of the string, does the copy and > returns a pointer to it. If there is no sufficient memory NULL is retur= ned > and the global errno is set to ENOMEM. > We do a sanity check to see if it was possible to allocate enough memor= y. > =20 > Also as we allocate memory, we need to free this memory used. Or it will > going out of scope leaks the storage it points to. > =20 > Reviewed by: rgrimes > MFC after: 3 weeks. > X-MFC: r332298 > Sponsored by: iXsystems Inc. > Differential Revision: https://reviews.freebsd.org/D15550 >=20 > Modified: > head/usr.sbin/bhyve/bhyverun.c >=20 > Modified: head/usr.sbin/bhyve/bhyverun.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/usr.sbin/bhyve/bhyverun.c Fri May 25 01:38:59 2018 (r334198) > +++ head/usr.sbin/bhyve/bhyverun.c Fri May 25 02:07:05 2018 (r334199) > @@ -193,6 +193,7 @@ topology_parse(const char *opt) > c =3D 1, n =3D 1, s =3D 1, t =3D 1; > ns =3D false, scts =3D false; > str =3D strdup(opt); > + assert(str !=3D NULL); Using assert seems like an odd choice when you've already added a failure path and the strsep will crash immediately if assert is elided. -- Brooks --PmA2V3Z32TCmWXqI Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEcBAEBAgAGBQJbCCelAAoJEKzQXbSebgfAKl0H/1Gr1OEC+uWvVxSm5ekFdFel grpqUm3jVJHneNGTm2Tj5oB66lMSBR7pfPB4g/xh7h/fPbQ+6UfKFJEQMeLBr1ff xVOcpzbmuuo30T7aqqv+on/SmYUgx0jcCvjf8eepR9ai8iSwYIvC9bytogOg8mU9 Bje+DOTJ3cjA0nlWfgnbgivF8edr6O0lksgi1ZOlNNYS/gV/aIY6M1DqUyI5O3cT g4EOEU524Qac5RcXX7u7bwvIoElEndYrPWrcK3croTSbplUawiZfMVvSlVZhFoX/ ZOQLCKOucLP0SZoB1K/5C78hF9EUIdPLs9aSxHqnGis7+1Q0atwYD7yylcPJzLY= =EQO3 -----END PGP SIGNATURE----- --PmA2V3Z32TCmWXqI--