Subject: Re: another word on 'digest'
To: Masao Uebayashi <uebayasi@soum.co.jp>
From: None <itojun@iijlab.net>
List: tech-pkg
Date: 03/09/2001 21:38:45
>>	I'm using very very latest pkgsrc tree, as I am supposed to.
>	I guess I now see the reason.  make(1) blows up with "make pre-install"
>	in pkgsrc/pkgtools/digest, if malloc.conf is set to AJ.  this means
>	that there's insufficient varaible initialization in make(1),
>	${MANZ:D.gz} is expanded into junk string.

	on usr.bin/make/var.c line 2601,
		Buf_Destroy(v->val, TRUE)
	is called.  because the value "str" points to inside the buffer
	due to the following line on 1860,
		str = (char *)Buf_GetAll(v->val, (int *)NULL);
	str is a dangling pointer after line 2601.

	the following patch corrected this problem for me.

itojun


Index: var.c
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/make/var.c,v
retrieving revision 1.56
diff -u -r1.56 var.c
--- var.c	2000/09/05 21:08:35	1.56
+++ var.c	2001/03/09 12:38:26
@@ -2584,7 +2584,7 @@
 	 * doesn't try to free a static pointer.
 	 * If VAR_KEEP is also set then we want to keep str as is.
 	 */
-	if (!(v->flags & VAR_KEEP)) {
+	if ((v->flags & VAR_KEEP) != 0) {
 	    if (*freePtr) {
 		free(str);
 	    }