From 3fd07e32e9a6a9d9cea26ef2362caa80ec109d0e Mon Sep 17 00:00:00 2001 From: Bruno Herrera Date: Sun, 30 Aug 2015 07:14:45 -0600 Subject: [PATCH] binfmt/builtin.c: Fix a memory leak: File was not being closed. --- ChangeLog | 3 +++ binfmt/builtin.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/ChangeLog b/ChangeLog index fc2b2decd2..6f6479b67b 100755 --- a/ChangeLog +++ b/ChangeLog @@ -10903,3 +10903,6 @@ * include/nuttx/mtd/mtd.h: Move MTD ioctl command definitions from include/nuttx/fs/fs.h to include/nuttx/mtd.h. Add ioctl commands to protect and unprotect memory (2015-08-29). + * binfmt/builtin.c: Fix a memory leak: File was not being closed. + From Bruno Herrera (2015-08-30). + diff --git a/binfmt/builtin.c b/binfmt/builtin.c index 4e6b18c9c4..537556136b 100644 --- a/binfmt/builtin.c +++ b/binfmt/builtin.c @@ -116,6 +116,7 @@ static int builtin_loadbinary(struct binary_s *binp) { int errval = get_errno(); bdbg("ERROR: FIOC_FILENAME ioctl failed: %d\n", errval); + close(fd); return -errval; } @@ -128,6 +129,7 @@ static int builtin_loadbinary(struct binary_s *binp) { int errval = get_errno(); bdbg("ERROR: %s is not a builtin application\n", filename); + close(fd); return -errval; } @@ -140,6 +142,7 @@ static int builtin_loadbinary(struct binary_s *binp) binp->entrypt = b->main; binp->stacksize = b->stacksize; binp->priority = b->priority; + close(fd); return OK; }