From owner-svn-src-head@freebsd.org Thu Aug 27 06:28:43 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D94469C3298; Thu, 27 Aug 2015 06:28:43 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CA7CB8B8; Thu, 27 Aug 2015 06:28:43 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7R6ShOY085487; Thu, 27 Aug 2015 06:28:43 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7R6ShaZ085486; Thu, 27 Aug 2015 06:28:43 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201508270628.t7R6ShaZ085486@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Thu, 27 Aug 2015 06:28:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287193 - head/usr.sbin/pkg X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Aug 2015 06:28:43 -0000 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);