util-lib: handle empty string in last_path_component
Now the function returns an empty string when given an empty string. Not sure if this is the best option (maybe this should be an error?), but at least the behaviour is well defined.
This commit is contained in:
@@ -719,6 +719,9 @@ const char *last_path_component(const char *path) {
|
||||
unsigned l, k;
|
||||
|
||||
l = k = strlen(path);
|
||||
if (l == 0) /* special case — an empty string */
|
||||
return path;
|
||||
|
||||
while (k > 0 && path[k-1] == '/')
|
||||
k--;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user