From 0a363852585c58405dc9fab7f5ec0c5550738fa8 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Mon, 15 Jan 2007 07:05:31 +0000 Subject: [PATCH] alloc buffer for getcwd svn: r5355 --- src/mzscheme/dynsrc/ustart.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mzscheme/dynsrc/ustart.c b/src/mzscheme/dynsrc/ustart.c index 7b11588914..710a5ddadb 100644 --- a/src/mzscheme/dynsrc/ustart.c +++ b/src/mzscheme/dynsrc/ustart.c @@ -140,6 +140,8 @@ static char *copy_string(char *s1) int l1; char *s; + if (!s1) return NULL; + l1 = strlen(s1); s = (char *)malloc(l1 + 1); @@ -199,6 +201,9 @@ char *absolutize(char *p, char *d) { int l1; + if (!p[0]) + return p; + if (p[0] == '/') return p; @@ -235,7 +240,10 @@ int main(int argc, char **argv) /* Absolute path */ } else if (has_slash(me)) { /* Relative path with a directory: */ - me = path_append(getcwd(NULL, 0), me); + char *buf; + long buflen = 4096; + buf = (char *)malloc(buflen); + me = path_append(getcwd(buf, buflen), me); } else { /* We have to find the executable by searching PATH: */ char *path = copy_string(getenv("PATH")), *p, *m;