unix/main: Free pathbuf when there's an error opening a file.

This commit is contained in:
小权一句两句 2022-10-22 14:05:25 +08:00 committed by Damien George
parent fb8792c095
commit 94ee1b629a
1 changed files with 1 additions and 0 deletions

View File

@ -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;