topology: fix the include path parsing

When the last '/' is not found use '.' as the source path.

Fixes: https://github.com/alsa-project/alsa-utils/issues/123
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2021-12-07 09:39:12 +01:00
parent e18913110b
commit 7692cfa0c5

View file

@ -240,8 +240,12 @@ static char *get_inc_path(const char *filename)
{ {
const char *s = strrchr(filename, '/'); const char *s = strrchr(filename, '/');
char *r = strdup(filename); char *r = strdup(filename);
if (r && s) if (r) {
r[s - filename] = '\0'; if (s)
r[s - filename] = '\0';
else if (r[0])
strcpy(r, ".");
}
return r; return r;
} }