Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!princeton!allegra!mit-eddie!genrad!panda!teddy!jpn From: jpn@teddy.UUCP Newsgroups: net.sources,net.sources.bugs Subject: findpaths: bus errors in malloc Message-ID: <3698@teddy.UUCP> Date: Thu, 22-Jan-87 16:00:11 EST Article-I.D.: teddy.3698 Posted: Thu Jan 22 16:00:11 1987 Date-Received: Sat, 24-Jan-87 09:04:47 EST Reply-To: jpn@teddy.UUCP (John P. Nelson) Organization: GenRad, Inc., Concord, Mass. Lines: 8 Xref: mnetor net.sources:3833 net.sources.bugs:960 I was getting bus errors in malloc() when I ran "findpaths" (only sometimes). I traced the bug down to this line: newftp->name = malloc(sizeof(file)+1); This is WRONG, since file is declared as a (char *), it always allocates 3 bytes, instead of enough space to hold the string for the subsequent strcpy. Change the "sizeof" to "strlen", and findpaths works great.