Skip to content

Commit 69d0a1c

Browse files
committed
unix: uClibc doesn't like NULL as a buffer arg to realpath().
So, allocate one explicitly.
1 parent a96cc82 commit 69d0a1c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

unix/main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ int main(int argc, char **argv) {
365365
return usage(argv);
366366
}
367367
} else {
368-
char *basedir = realpath(argv[a], NULL);
368+
char *pathbuf = malloc(PATH_MAX);
369+
char *basedir = realpath(argv[a], pathbuf);
369370
if (basedir == NULL) {
370371
fprintf(stderr, "%s: can't open file '%s': [Errno %d] ", argv[0], argv[a], errno);
371372
perror("");
@@ -377,7 +378,7 @@ int main(int argc, char **argv) {
377378
// Set base dir of the script as first entry in sys.path
378379
char *p = strrchr(basedir, '/');
379380
path_items[0] = MP_OBJ_NEW_QSTR(qstr_from_strn(basedir, p - basedir));
380-
free(basedir);
381+
free(pathbuf);
381382

382383
for (int i = a; i < argc; i++) {
383384
mp_obj_list_append(mp_sys_argv, MP_OBJ_NEW_QSTR(qstr_from_str(argv[i])));

0 commit comments

Comments
 (0)