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);
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to