- local = start = pathbuf = malloc(strlen(path) + 1);
- buf = malloc(strlen(path) + strlen(argv0) + 2);
- strcpy(pathbuf, path);
+ bufsize = strlen(path) + 1;
+ start = pathbuf = alloca(bufsize);
+ if (pathbuf == NULL) return NULL; /* XXX can't happen */
+ strlcpy(pathbuf, path, bufsize);
+ bufsize += sizeof "/" - 1 + strlen(argv0);
+ buf = malloc(bufsize);
+ if (buf == NULL) return NULL; /* XXX can't happen */