From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4885 invoked from network); 1 Jun 2000 06:25:20 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 1 Jun 2000 06:25:20 -0000 Received: (qmail 12371 invoked by alias); 1 Jun 2000 06:25:15 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11705 Received: (qmail 12364 invoked from network); 1 Jun 2000 06:25:14 -0000 Message-ID: <20000601062512.29057.qmail@web1303.mail.yahoo.com> Date: Wed, 31 May 2000 23:25:12 -0700 (PDT) From: Felix Rosencrantz Subject: Re: PATCH: Memorey leak with PS4 usage. To: zsh-workers MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii --- Bart Schaefer wrote: > On May 31, 8:27pm, Felix Rosencrantz wrote: > } Subject: PATCH: Memorey leak with PS4 usage. > } > } There seems to be a memory leak issue with the use of promptexpand. > } I've included a patch for utils.c. > > What leads you to this conclusion? > > dupstring() allocates off zsh's internal heap. Freeing a pointer off the > heap is a Bad Thing. The heap is allocated and freed in large chunks that > zsh subdivides as necessary. I think the these lines in promptexpand: prompt.c:144: return ztrdup(""); prompt.c:163: bp =bufline = buf = zcalloc(bufspc = 256); Are not allocated off the internal heap. Also, other uses of promptexpand use free to free this space. For example, in bin_print(): builtin.c:2758 if(ops['P']) { builtin.c:2759 /* builtin.c:2760 * promptexpand uses permanent storage: to avoid builtin.c:2761 * messy memory management, stick it on the heap builtin.c:2762 * instead. builtin.c:2763 */ builtin.c:2764 char *str = unmetafy(promptexpand(metafy(args[n], len[n], builtin.c:2765 META_NOALLOC), 0, NULL, NULL), &len[n]); builtin.c:2766 args[n] = dupstring(str); builtin.c:2767 free(str); builtin.c:2768 } Is this correct? Plus, that comment is unclear to me. Though code speaks louder than comments. -FR. __________________________________________________ Do You Yahoo!? Send instant messages & get email alerts with Yahoo! Messenger. http://im.yahoo.com/