Skip to content

Commit

Permalink
unix/main: Free pathbuf when there's an error opening a file.
Browse files Browse the repository at this point in the history
  • Loading branch information
xqyjlj authored and dpgeorge committed Jan 20, 2023
1 parent fb8792c commit 94ee1b6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions ports/unix/main.c
Expand Up @@ -699,6 +699,7 @@ MP_NOINLINE int main_(int argc, char **argv) {
char *basedir = realpath(argv[a], pathbuf);
if (basedir == NULL) {
mp_printf(&mp_stderr_print, "%s: can't open file '%s': [Errno %d] %s\n", argv[0], argv[a], errno, strerror(errno));
free(pathbuf);
// CPython exits with 2 in such case
ret = 2;
break;
Expand Down

0 comments on commit 94ee1b6

Please sign in to comment.