summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/user/lib/elfload.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/user/lib/elfload.c b/src/user/lib/elfload.c
index 7b92d35..c1a08f8 100644
--- a/src/user/lib/elfload.c
+++ b/src/user/lib/elfload.c
@@ -10,6 +10,7 @@
#include <elfload.h>
void elf_execf(FILE *f, char **argv, char **envp) {
+ size_t ret;
void *buf;
long buflen;
@@ -20,8 +21,12 @@ void elf_execf(FILE *f, char **argv, char **envp) {
// TODO don't read the entire file into memory
fseek(f, 0, SEEK_SET);
- if (buf && fread(buf, 1, buflen, f))
+ if (!buf) return;
+ ret = fread(buf, buflen, 1, f);
+ fclose(f);
+ if (ret == 1) {
elf_exec(buf, argv, envp);
+ }
free(buf);
}