Strcpy fun w/ UltrixREAD/NEW/FOLLOWUP

Generics Software Ltd. gsl3 at csvax1.cs.tcd.ie
Wed May 3 21:35:42 AEST 1989


In article <cYLAeIy00Vsn02rps8 at andrew.cmu.edu>, bobg+ at andrew.cmu.edu (Robert Steven Glickstein) writes:
>> Excerpts from ext.nn.comp.lang.c: 27-Apr-89 Strcpy fun w/ Ultrix
>> tim at scsmo1.UUCP (618)
> 
> 
>> I ran accross a problem with strcpy in ultrix, for some reason it will
>> not return its first argument.  This is something like the "buged" code:
>> x->name=strcpy(malloc(strlen(in)+1),in);
>> The solution was:
>> strcpy(x->name=malloc(strlen(in)+1),in);
> 
> Danger, Will Robinson!  Bad programming style alert!
> 
> Do you WANT to dump core if malloc returns NULL?
> 
> -Bob Glickstein

We should be so lucky, most of the ultrix implementation of string 
manipulation functions quite happily take a NULL pointer. I discovered
this when porting the code to a VMS machine. It was promptly sick when
passed the  NULL pointer. The moral of the story, check your return
values.

 Andy Trayler

 trayler at genrix.uucp  trayler at genrix.ie 
 ..!mcvax!einode!genrix!trayler

 | ... What, ME naive ! :^) |



More information about the Comp.lang.c mailing list