lkml.org 
[lkml]   [2002]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] 2.5.47: strdup()
Date
Peter Kjellerstedt <peter.kjellerstedt@axis.com> writes:

>> +char *strdup(const char *s)
>> +{
>> + char *p = kmalloc(strlen(s) + 1, GFP_KERNEL);
>> + if (p)
>> + strcpy(p, s);
>> +
>> + return p;
>> }
>> #endif
>
> You should make sure s != NULL before doing anything else.

Like strcpy(), it's the caller's responsibility to provide a valid
pointer. This shouldn't be a problem however, since access to NULL
triggers an Oops and thus is quickly detected.

Regards, Olaf.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

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