commit d6f31243d52264483e18fbd7c362c386ce2bf83a
parent d407878575deae22768fc120f158d5f5ad6f88c8
Author: Louis Burda <contact@sinitax.com>
Date: Thu, 27 Feb 2025 10:28:38 +0100
Fix path resolution
Diffstat:
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/mplay.c b/mplay.c
@@ -60,8 +60,7 @@ main(int argc, char **argv)
end = sep ? sep : tok + strlen(tok);
*end = '\0';
dir = opendir(tok);
- if (!dir) continue;
- while ((ent = readdir(dir))) {
+ while (dir && (ent = readdir(dir))) {
if (!strncmp(ent->d_name, "mplay.", 6)
&& !strcmp(ent->d_name + 6, fmt)) {
bin = malloc(strlen(tok) + strlen(ent->d_name) + 2);
@@ -74,7 +73,7 @@ main(int argc, char **argv)
die("execv %s:", bin);
}
}
- closedir(dir);
+ if (dir) closedir(dir);
tok = sep + 1;
} while (sep);