diff options
author | delphij <delphij@FreeBSD.org> | 2015-08-27 06:28:42 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2015-08-27 06:28:42 +0000 |
commit | 12b0d76c86e1bec547d56a57bd17c4da1885b903 (patch) | |
tree | ce8febe8d7c8a866c749cbe65fe6de4a9d01f0f3 /usr.sbin/pkg | |
parent | 22301795e1b9bc2896e418e3a0b126a1061fa282 (diff) | |
download | FreeBSD-src-12b0d76c86e1bec547d56a57bd17c4da1885b903.zip FreeBSD-src-12b0d76c86e1bec547d56a57bd17c4da1885b903.tar.gz |
Plug a possible memory leak.
MFC after: 2 weeks
Diffstat (limited to 'usr.sbin/pkg')
-rw-r--r-- | usr.sbin/pkg/dns_utils.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.sbin/pkg/dns_utils.c b/usr.sbin/pkg/dns_utils.c index ce88048..a3c3a7e 100644 --- a/usr.sbin/pkg/dns_utils.c +++ b/usr.sbin/pkg/dns_utils.c @@ -84,7 +84,6 @@ compute_weight(struct dns_srvinfo **d, int first, int last) 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, int first, int last) 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); |