summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author小权一句两句 <xqyjlj@126.com>2022-10-22 14:05:25 +0800
committerDamien George <damien@micropython.org>2023-01-20 19:38:14 +1100
commit94ee1b629a18429a92fc0475e7318c6a48dabd2a (patch)
tree460e6d3c51c3949f665534f88d363ede43b8b1db
parentfb8792c095802a9fcc8b38c1d8cbc3f641918433 (diff)
unix/main: Free pathbuf when there's an error opening a file.
-rw-r--r--ports/unix/main.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/ports/unix/main.c b/ports/unix/main.c
index 7920db02f..d6ae1e611 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;