]> cloudbase.mooo.com Git - z180-stamp.git/commitdiff
Remove xmalloc.c, fix potential 0-pointer derefenrence in cli.c.
authorLeo C <erbl259-lmu@yahoo.de>
Sat, 21 Jul 2018 11:38:25 +0000 (13:38 +0200)
committerLeo C <erbl259-lmu@yahoo.de>
Sat, 21 Jul 2018 11:45:29 +0000 (13:45 +0200)
# Conflicts:
# avr/cli.c

avr/Tupfile
avr/cli.c
avr/env.c
avr/xmalloc.c [deleted file]
include/xmalloc.h [deleted file]

index d650514080e4e07a8d8db5081ff2b50c78d97866..5e1f305229e38fddaa4c5a222a3b6e43a7ddbe21 100644 (file)
@@ -10,8 +10,7 @@ SRC           += cli.c cli_readline.c command.c command_tbl.c
 SRC            += cmd_run.c cmd_boot.c cmd_misc.c
 SRC            += cmd_date.c cmd_mem.c cmd_gpio.c cmd_attach.c
 SRC            += cmd_loadihex.c cmd_loadcpm3.c cmd_sd.c cmd_fat.c
-SRC            += env.c xmalloc.c con-utils.c print-utils.c
-SRC            += getopt-min.c eval_arg.c
+SRC            += env.c con-utils.c print-utils.c getopt-min.c eval_arg.c
 SRC            += timer.c serial.c i2c.c bcd.c pcf8583.c mmc.c
 SRC            += background.c z180-serv.c z80-if.c gpio.c
 SRC            += $(FATFS)
@@ -97,6 +96,7 @@ ASFLAGS += -mmcu=$(MCU_TARGET) -x assembler-with-cpp $(ASFLAGS)
 # Linker flags
 LDFLAGS        += -Wl,--gc-sections
 LDFLAGS        += -Wl,--cref
+#LDFLAGS += -flto -Os
 
 # Assemble: create object files from assembler source files.
 #.S.o:
index 8a62bc054a34c19bc9db604c838b475868f1a4c9..b47603a7841c5841a32a625f3c341e579ca1243b 100644 (file)
--- a/avr/cli.c
+++ b/avr/cli.c
  */
 
 #include "cli.h"
-#include "common.h"
-
-#include <string.h>
+#include "command.h"
 #include <ctype.h>
-#include <stdlib.h>
-#include <stdio.h>
 
 #include "config.h"
-#include "command.h"
 #include "debug.h"
 #include "env.h"
 #include "cli_readline.h"
index 4f37590e891f8cad0e65c77dc708f8b1a2c18b23..b2b4e6fd1fa0b66828cd8071060290cffffbbf8f 100644 (file)
--- a/avr/env.c
+++ b/avr/env.c
@@ -9,7 +9,6 @@
 
 #include "config.h"
 #include "debug.h"
-#include "xmalloc.h"
 #include "crc.h"
 #include "getopt-min.h"
 
@@ -195,7 +194,7 @@ int envlist_import(uint8_t flags)
                                return -1;
                }
 
-               np = (char *) xmalloc(len+1);
+               np = (char *) malloc(len+1);
                if (np == NULL) {
                        printf_P(PSTR("## Can't malloc %d bytes\n"), len+1);
                        return 1;
@@ -488,7 +487,7 @@ command_ret_t _do_env_set(uint_fast8_t flag, int argc, char * const argv[])
        for (i = 2, len += 1; i < argc; ++i)
                len += strlen(argv[i]) + 1;
 
-       value = xmalloc(len);
+       value = malloc(len);
        if (value == NULL) {
                printf_P(PSTR("## Can't malloc %d bytes\n"), len);
                return CMD_RET_FAILURE;
diff --git a/avr/xmalloc.c b/avr/xmalloc.c
deleted file mode 100644 (file)
index d42d5c9..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * (C) Copyright 2014 Leo C. <erbl259-lmu@yahoo.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <stdlib.h>
-#include "debug.h"
-#include "xmalloc.h"
-
-void* xmalloc(size_t size)
-{
-       void *p;
-
-       p = malloc(size);
-
-       if (p == NULL)
-               debug("*** Out of memory!\n");
-
-       return p;
-}
-
-
-void* xrealloc(void *p, size_t size)
-{
-       p = realloc(p, size);
-
-       if (p == NULL)
-               debug("*** Out of memory!\n");
-
-       return p;
-}
diff --git a/include/xmalloc.h b/include/xmalloc.h
deleted file mode 100644 (file)
index cb0019f..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-
-#ifndef XMALLOC_H
-#define XMALLOC_H
-
-void* xmalloc(size_t size);
-void* xrealloc(void *p, size_t size);
-
-#endif /* XMALLOC_H */