From 94ee1b629a18429a92fc0475e7318c6a48dabd2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=9D=83=E4=B8=80=E5=8F=A5=E4=B8=A4=E5=8F=A5?= Date: Sat, 22 Oct 2022 14:05:25 +0800 Subject: [PATCH] unix/main: Free pathbuf when there's an error opening a file. --- ports/unix/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/unix/main.c b/ports/unix/main.c index 7920db02f2..d6ae1e611b 100644 --- a/ports/unix/main.c +++ b/ports/unix/main.c @@ -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;