Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 May 1999 23:23:51 +0100 (BST)
From:      iedowse@maths.tcd.ie
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/11900: Sed(1) fails with MALLOC_OPTIONS set to 'V'
Message-ID:  <199905262323.aa75046@gosset.maths.tcd.ie>

next in thread | raw e-mail | index | archive | help

>Number:         11900
>Category:       bin
>Synopsis:       Sed(1) fails with MALLOC_OPTIONS set to 'V'
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 26 15:30:01 PDT 1999
>Closed-Date:
>Last-Modified:
>Originator:     Ian Dowse
>Release:        FreeBSD 3.1-STABLE i386
>Organization:
	School of Mathematics
	Trinity College, Dublin
>Environment:
	All versions of FreeBSD

>Description:

	Just a trivial buglet; the synopsis says it all.

	Sed's compile() function can try to malloc zero bytes, and its
	xmalloc() wrapper treats a NULL malloc() return as a fatal error.

	Presumably other similar problems exist elsewhere in the tree. I
	just tried a 'setenv MALLOC_OPTIONS AJVX; make world' and almost
	immediately ld(1) gave a similar error (on a 2-week old -current).
	While not at all critical, it would be nice for standard utilities
	to work with any malloc options.
	
>How-To-Repeat:

	% setenv MALLOC_OPTIONS V
	% sed
	sed: malloc: Undefined error: 0
>Fix:

Apply this patch to src/usr.bin/sed/compile.c

--- compile.c.orig	Wed May 26 21:19:18 1999
+++ compile.c	Wed May 26 21:23:43 1999
@@ -138,7 +138,10 @@
 	*compile_stream(&prog) = NULL;
 	fixuplabel(prog, NULL);
 	uselabel();
-	appends = xmalloc(sizeof(struct s_appends) * appendnum);
+	if (appendnum > 0)
+		appends = xmalloc(sizeof(struct s_appends) * appendnum);
+	else
+		appends = NULL;
 	match = xmalloc((maxnsub + 1) * sizeof(regmatch_t));
 }
 


>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199905262323.aa75046>