summaryrefslogtreecommitdiff
path: root/cgpt
diff options
context:
space:
mode:
Diffstat (limited to 'cgpt')
-rw-r--r--cgpt/cgpt_nor.c1
-rw-r--r--cgpt/cmd_find.c6
2 files changed, 6 insertions, 1 deletions
diff --git a/cgpt/cgpt_nor.c b/cgpt/cgpt_nor.c
index bf0a1764..d2e7eafa 100644
--- a/cgpt/cgpt_nor.c
+++ b/cgpt/cgpt_nor.c
@@ -77,6 +77,7 @@ int ForkExecL(const char *cwd, const char *cmd, ...) {
const char **argv = calloc(argc + 1, sizeof(char *));
if (argv == NULL) {
errno = ENOMEM;
+ va_end(ap);
return -1;
}
argv[0] = cmd;
diff --git a/cgpt/cmd_find.c b/cgpt/cmd_find.c
index d0f048f2..68ba6a85 100644
--- a/cgpt/cmd_find.c
+++ b/cgpt/cmd_find.c
@@ -37,6 +37,7 @@ static void Usage(void)
static uint8_t *ReadFile(const char *filename, uint64_t *size) {
FILE *f;
uint8_t *buf;
+ long pos;
f = fopen(filename, "rb");
if (!f) {
@@ -44,7 +45,10 @@ static uint8_t *ReadFile(const char *filename, uint64_t *size) {
}
fseek(f, 0, SEEK_END);
- *size = ftell(f);
+ pos = ftell(f);
+ if (pos < 0)
+ return NULL;
+ *size = pos;
rewind(f);
buf = malloc(*size);