Subject: Re: The _weirdest_ segfault...
To: Peter Seebach <>
From: Robert Elz <kre@munnari.OZ.AU>
List: port-alpha
Date: 05/18/2000 08:36:18
    Date:        Wed, 17 May 2000 17:11:43 -0500
    From: (Peter Seebach)
    Message-ID:  <>

  | In particular, look for malloc(0).

One of the most common beginner errors with malloc is ...

	char *ptr;
	char *space;
	/* get a string that needs to be saved pointed at by ptr */

	space = (char *)malloc(sizeof(ptr));
	strcpy(space, ptr);			/* bang, malloc data dies */

The other is failing to allocate an extra byte for the \0 on strings

	space = (char *)malloc(strlen(ptr));
	strcpy(space, ptr);			/* bang again */

the latter is entirely possibly something which will have markedly
different effects on alpha and i386.