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;