Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 May 2018 15:11:34 +0000
From:      Brooks Davis <brooks@freebsd.org>
To:        Marcelo Araujo <araujo@FreeBSD.org>
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>
In-Reply-To: <201805250207.w4P275Pf060725@repo.freebsd.org>
References:  <201805250207.w4P275Pf060725@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180525151134.GB99063>