Date: Sat, 31 Dec 2016 13:55:18 -0800 From: "Ngie Cooper (yaneurabeya)" <yaneurabeya@gmail.com> To: Pedro Giffuni <pfg@FreeBSD.org> Cc: Ngie Cooper <ngie@FreeBSD.org>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r310984 - head/lib/libc/net Message-ID: <371A5B4E-0766-49F4-9115-13598B3E74FF@gmail.com> In-Reply-To: <7914bb49-6bef-6bbd-5574-ceb29f318c01@FreeBSD.org> References: <201612312100.uBVL09RR092355@repo.freebsd.org> <7914bb49-6bef-6bbd-5574-ceb29f318c01@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_867E2280-4CAE-477F-8AD1-C825FC4B1A12 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Dec 31, 2016, at 13:49, Pedro Giffuni <pfg@FreeBSD.org> wrote: >=20 >=20 >=20 > On 12/31/16 16:00, Ngie Cooper wrote: >> Author: ngie >> Date: Sat Dec 31 21:00:08 2016 >> New Revision: 310984 >> URL: https://svnweb.freebsd.org/changeset/base/310984 >>=20 >> Log: >> Use calloc instead of malloc + memset(.., 0, ..) >>=20 >> MFC after: 1 week >>=20 >> Modified: >> head/lib/libc/net/getaddrinfo.c >>=20 >> Modified: head/lib/libc/net/getaddrinfo.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/lib/libc/net/getaddrinfo.c Sat Dec 31 19:59:31 2016 = (r310983) >> +++ head/lib/libc/net/getaddrinfo.c Sat Dec 31 21:00:08 2016 = (r310984) >> @@ -691,9 +691,8 @@ reorder(struct addrinfo *sentinel) >> return(n); >>=20 >> /* allocate a temporary array for sort and initialization of it. = */ >> - if ((aio =3D malloc(sizeof(*aio) * n)) =3D=3D NULL) >> + if ((aio =3D calloc(1, sizeof(*aio) * n)) =3D=3D NULL) >> return(n); /* give up reordering */ >=20 > This should be calloc(n, sizeof(*aio))) >=20 > FWIW, the other cases are not very useful. > Generally, replacing any malloc(x) with a calloc(1, x) doesn't bring = any advantage as it won't catch any overflow. Yeah, that would have been better. The goal was to reduce complexity. I found some memory leaks with = valgrind with bsnmp* last night involving getaddrinfo that I=E2=80=99m = trying to chase down, and I noticed these while =E2=80=9Cin the = neighborhood=E2=80=9D. Thanks! -Ngie --Apple-Mail=_867E2280-4CAE-477F-8AD1-C825FC4B1A12 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJYaClGAAoJEPWDqSZpMIYV1E8QAKvomvKcUWo7fD1sF5t4YU7N jX6jwiOgzgr9y1Ur34xETJTaHaFCjV5+xa5mQCdKQv4E2LPbwjUfH1qHH9P0DDFX KgP34vgYiahrBJcUwpeYhNPXhl+i2gLQ1Tnu2G8gbOzGnf0nWKTgoZ56c0ZAE3zW OEdn4AU9KBeeNliuEc8j54Z6HxGq8biqm6ymS6ZHHGBRjlIHdT5FFIXscIKQW1eD 3H6pX+8ZNfu+OkWQMJbT2lkMswJRBFYC8hYrqUqZbk8etaj9gABaZ2szIyNbTq+x LYtK3qEirXyfcHEYmlrzBuItI73J3hymyGyWRog3M7Pfw2jZ151ACmwtDWcbT4er tBoooYqHRSLB67GB2MI1tWXYDQUnBnuYgm4oKxwxyGo5zHp+UdLWGE9ChPx5LjwF /hQeUF43EpUnT21Pgq/qWuFNHyOd+TeOT0kgch/pvkUD8L5/Q0/jYpexDvcKmJQr ndxYov/KY4IVkmCwiih0POVd44VaPqTUlIal7POIGWgfR9HK/izSX3Lx+5GnY5Qr 7gepw4gxLROuDEK+r834XeNY8zcfV7eGie10P6enB0zfZ3Qh2a9YNSZZSfZZkNaZ KB0DUDqWtBnBaKRsI8tU6tuXNZTlpYP1AN/PklBzj6gCnyFlHAEU96tAY+KBdj4K 3C75vbRrfti5cHoIBoRi =IcFw -----END PGP SIGNATURE----- --Apple-Mail=_867E2280-4CAE-477F-8AD1-C825FC4B1A12--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?371A5B4E-0766-49F4-9115-13598B3E74FF>