From: ltf@ncmicro.lonestar.org (Lance Franklin)
Subject: Re: strcat(foo,NULL) core dumps on Ultrix
Date: 12 Jun 91 17:05:57 GMT [thread overview]
Message-ID: <400@ncmicro.lonestar.org> (raw)
In-Reply-To: 966@sdrc.COM
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 +----------------------------------------------+
prev parent reply other threads:[~1991-06-12 17:05 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1991-06-11 12:34 strcat(foo,NULL) core dumps on Ultrix Rob Gabbard
1991-06-12 4:00 ` Larry Meehan
1991-06-12 6:20 ` Norman Diamond
1991-06-12 21:41 ` Larry Meehan
1991-06-13 7:20 ` Norman Diamond
1991-06-12 4:12 ` Norman Diamond
1991-06-12 4:34 ` George Robbins
1991-06-12 17:05 ` Lance Franklin [this message]
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox