From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHsKI-00036g-DZ for qemu-devel@nongnu.org; Thu, 14 Aug 2014 06:32:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHsKD-0008Rn-Jh for qemu-devel@nongnu.org; Thu, 14 Aug 2014 06:32:10 -0400 Date: Thu, 14 Aug 2014 12:31:37 +0200 From: "Michael S. Tsirkin" Message-ID: <20140814103137.GF31346@redhat.com> References: <1408001361-13580-1-git-send-email-zhang.zhanghailiang@huawei.com> <1408001361-13580-7-git-send-email-zhang.zhanghailiang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <1408001361-13580-7-git-send-email-zhang.zhanghailiang@huawei.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v6 06/10] slirp/misc: Use g_malloc() instead of malloc() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: zhanghailiang Cc: kwolf@redhat.com, lkurusa@redhat.com, qemu-trivial@nongnu.org, jan.kiszka@siemens.com, riku.voipio@iki.fi, mjt@tls.msk.ru, qemu-devel@nongnu.org, lcapitulino@redhat.com, stefanha@redhat.com, luonengjun@huawei.com, pbonzini@redhat.com, peter.huangpeng@huawei.com, alex.bennee@linaro.org, rth@twiddle.net On Thu, Aug 14, 2014 at 03:29:17PM +0800, zhanghailiang wrote: > Here we don't check the return value of malloc() which may fail. > Use the g_malloc() instead, which will abort the program when > there is not enough memory. >=20 > Signed-off-by: zhanghailiang > Reviewed-by: Alex Benn=E9e OK, but then we need to find and replace free calls as well. > --- > slirp/misc.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/slirp/misc.c b/slirp/misc.c > index b8eb74c..f7fe497 100644 > --- a/slirp/misc.c > +++ b/slirp/misc.c > @@ -54,7 +54,7 @@ int add_exec(struct ex_list **ex_ptr, int do_pty, cha= r *exec, > } > =20 > tmp_ptr =3D *ex_ptr; > - *ex_ptr =3D (struct ex_list *)malloc(sizeof(struct ex_list)); > + *ex_ptr =3D (struct ex_list *)g_malloc(sizeof(struct ex_list)); > (*ex_ptr)->ex_fport =3D port; > (*ex_ptr)->ex_addr =3D addr; > (*ex_ptr)->ex_pty =3D do_pty; > @@ -235,7 +235,7 @@ strdup(str) > { > char *bptr; > =20 > - bptr =3D (char *)malloc(strlen(str)+1); > + bptr =3D (char *)g_malloc(strlen(str)+1); > strcpy(bptr, str); > =20 > return bptr; > --=20 > 1.7.12.4 >=20