Additional check with NULL or empty string (now same behaviour as POSIX version)
This commit is contained in:
parent
78899705d5
commit
7973e87b2f
|
@ -12,12 +12,22 @@ void sys_basename(char *str, register char *dst)
|
|||
register char *p2 = p1;
|
||||
register char *end;
|
||||
register char *start;
|
||||
int len;
|
||||
|
||||
int len = strlen(str);
|
||||
if ((str == NULL) || (*str == '\0'))
|
||||
{
|
||||
dst[0] = '.';
|
||||
dst[1] = '\0';
|
||||
return;
|
||||
}
|
||||
|
||||
len = strlen(str);
|
||||
/* Point to the end of the string. */
|
||||
p1 = p1 + len - 1;
|
||||
end = p1;
|
||||
|
||||
|
||||
|
||||
while ((*p1 == '/') || (*p1 == '\\'))
|
||||
{
|
||||
if (p1 == str)
|
||||
|
|
Loading…
Reference in a new issue