Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!west!texsun!csccat!ncmicro!ltf From: ltf@ncmicro.lonestar.org (Lance Franklin) Newsgroups: comp.sys.dec Subject: Re: strcat(foo,NULL) core dumps on Ultrix Keywords: dec c strcat Message-ID: <400@ncmicro.lonestar.org> Date: 12 Jun 91 17:05:57 GMT References: <966@sdrc.COM> Organization: NC Microproducts, Inc. Richardson, Tx Lines: 35 In article <966@sdrc.COM> wggabb@sdrc.COM (Rob Gabbard) writes: }A call to strcat with NULL as the second argument core dumps with a memory }fault on Ultrix. Why would anyone want to do this anyway ? How about.... } } strcat(foo,getenv("FOO")) } } instead of } } if (getenv("FOO")) strcat(foo,getenv("FOO")); Try: if ((s=getenv("FOO"))) strcat(foo,s); Where s is defined as (char *). } }Actually, just coding strcat(foo,NULL) will dump. Anyone run into this ? }Am I doing a no-no here. Yup...figure it out, why put up with a lot of overhead on error checking on string handling routines where 95% of the calls are of the type: strcat(foo,"string"); After all, if you check for NULL on strcat, you might as well do it in all the other str* routines...that's a lot of error checking in a set of routines you would prefer to be as fast as possible. Lance -- Lance T. Franklin +----------------------------------------------+ (ltf@ncmicro.lonestar.org) | "You want I should bop you with this here | NC Microproducts, Inc. | Lollipop?!?" The Fat Fury | Richardson, Texas +----------------------------------------------+