summaryrefslogtreecommitdiff
path: root/src/glob
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-23 20:45:22 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-23 20:45:22 -0500
commit856c67d363f02506577fbf904b941056354a0e98 (patch)
treef23f3ebc33374a9e47ed09fe46838c77f2e497b4 /src/glob
parent9440352c02ab469207e3a09dde6b1be5654a3d53 (diff)
don't use strdup() before it's available
Diffstat (limited to 'src/glob')
-rw-r--r--src/glob/glob.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/glob/glob.c b/src/glob/glob.c
index e8e6b8a6..3de2532e 100644
--- a/src/glob/glob.c
+++ b/src/glob/glob.c
@@ -36,7 +36,8 @@ int glob(const char * restrict pattern, int flags, int (*errfunc) (const char *
}
}
- char *path = strdup(pattern);
+ char *path = malloc(strlen(pattern) + 1);
+ strcpt(path, pattern);
for (i = 0; path[i]; i++) {
if (path[i] == '/') {
@@ -81,7 +82,8 @@ int glob(const char * restrict pattern, int flags, int (*errfunc) (const char *
pglob->gl_pathv = tmp;
/* FIXME: add path to front */
- pglob->gl_pathv[pglob->gl_pathc - 1] = strdup(de->d_name);
+ pglob->gl_pathv[pglob->gl_pathc - 1] = malloc(strlen(de->d_name) + 1);
+ strcat(pglob->gl_pathv[pglob->gl_pathc - 1], de->d_name);
/* TODO: MARK */
}
}
@@ -97,7 +99,8 @@ int glob(const char * restrict pattern, int flags, int (*errfunc) (const char *
/* TODO: DOOFFS */
pglob->gl_pathc = 1;
pglob->gl_pathv = malloc(sizeof(char*));
- pglob->gl_pathv[0] = strdup(pattern);
+ pglob->gl_pathv[0] = malloc(strlen(pattern) + 1);
+ strcpy(pglob->gl_pathv[0], pattern);
} else {
return GLOB_NOMATCH;
}