[lkml]   [2003]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [BK PATCH] One strdup() to rule them all
On Mon, 25 August 2003 19:55:12 +0300, Dan Aloni wrote:
> >
> > My gut feeling is always afraid when something "must not be NULL",
> > someone will ignore this and Bad Things (tm) happen. Is strdup ever
> > used such performance critical code that the extra check would hurt?
> There are two reasons while it shouldn't have a NULL check. One,
> persistency: the other str*() functions don't do this sort of check.
> Two, for general uses like that:
> new_name = strdup(name);
> if (!new_name)
> goto allocation_failed;
> With this check, NULL would be returning from strdup() either because
> name == NULL or when the allocation fails.

True, I missed that one.

> Passing NULL to strdup() is a bug, which would have NOT show as an
> Oops if you add this check, and that is bad. Maybe it would be worth
> to add a BUG_ON(s == NULL) instead, and perhaps also add this to the
> other str*() functions, but that is a different patch.

Ok. Will you write that patch then or do I have to put it onto my


When in doubt, use brute force.
-- Ken Thompson
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 13:48    [W:0.055 / U:29.752 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site