string: fix NULL pointer dereferences
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
f177a8e65d
commit
1dde87423d
1 changed files with 4 additions and 0 deletions
|
|
@ -225,6 +225,8 @@ char *dirname(const char *path)
|
|||
if (!path)
|
||||
return strdup(".");
|
||||
char *copy = strdup(path);
|
||||
if (!copy)
|
||||
return NULL;
|
||||
char *res = udirname(copy);
|
||||
char *ret = strdup(res);
|
||||
kfree(copy);
|
||||
|
|
@ -236,6 +238,8 @@ char *basename(const char *path)
|
|||
if (!path)
|
||||
return strdup(".");
|
||||
char *copy = strdup(path);
|
||||
if (!copy)
|
||||
return NULL;
|
||||
char *res = ubasename(copy);
|
||||
char *ret = strdup(res);
|
||||
kfree(copy);
|
||||
|
|
|
|||
Loading…
Reference in a new issue