Date: Thu, 27 Aug 2015 06:28:43 +0000 (UTC) From: Xin LI <delphij@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287193 - head/usr.sbin/pkg Message-ID: <201508270628.t7R6ShaZ085486@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: delphij Date: Thu Aug 27 06:28:42 2015 New Revision: 287193 URL: https://svnweb.freebsd.org/changeset/base/287193 Log: Plug a possible memory leak. MFC after: 2 weeks Modified: head/usr.sbin/pkg/dns_utils.c Modified: head/usr.sbin/pkg/dns_utils.c ============================================================================== --- head/usr.sbin/pkg/dns_utils.c Thu Aug 27 05:39:32 2015 (r287192) +++ head/usr.sbin/pkg/dns_utils.c Thu Aug 27 06:28:42 2015 (r287193) @@ -84,7 +84,6 @@ compute_weight(struct dns_srvinfo **d, i int i, j, totalweight; int *chosen; - chosen = malloc(sizeof(int) * (last - first + 1)); totalweight = 0; for (i = 0; i <= last; i++) @@ -93,6 +92,8 @@ compute_weight(struct dns_srvinfo **d, i if (totalweight == 0) return; + chosen = malloc(sizeof(int) * (last - first + 1)); + for (i = 0; i <= last; i++) { for (;;) { chosen[i] = random() % (d[i]->weight * 100 / totalweight);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508270628.t7R6ShaZ085486>