*BSD News Article 18429


Return to BSD News archive

Path: sserve!newshost.anu.edu.au!munnari.oz.au!bunyip.cc.uq.oz.au!uqcspe!cs.uq.oz.au!shocking
From: shocking@cs.uq.oz.au (Stephen Hocking)
Newsgroups: comp.os.386bsd.development
Subject: patch for kvm.c
Summary: Fixes memory leak
Keywords: patch libutil
Message-ID: <14354@uqcspe.cs.uq.oz.au>
Date: 15 Jul 93 08:41:11 GMT
Sender: news@cs.uq.oz.au
Reply-To: shocking@cs.uq.oz.au
Lines: 30


	Find enclosed a patch to kvm.c (/usr/src/lib/libutil) which fixes a
memory leak experienced by programs which use some functions (kvm_tprocs) as
part of a loop)

421c421
<       static int      ocopysize = -1;
---
>       static int      ocopysize = -1, biggestsize = -1;
433,434c433,436
<               if (copysize > ocopysize &&
<                       (kvmprocbase = (struct kinfo_proc *)malloc(copysize)) 
---
>               if (copysize > biggestsize)
>               {
>                       kvm_freeprocs();
>                       if ((kvmprocbase = (struct kinfo_proc *)malloc(copysize)) 
436,437c438,441
<                       seterr("out of memory");
<                       return (-1);
---
>                               seterr("out of memory");
>                               return (-1);
>                       }
>                       biggestsize = copysize;
--
            "Toddlers are the stormtroopers of the Lords of Entropy"

shocking@cs.uq.oz.au				Phone (w) +61 7 227 5068
						      (h) +61 7 899 1766