From 85c6181c2c9af0d95b398639a56587f1497b5608 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Thu, 2 Aug 2018 14:35:07 +1000 Subject: mem: Avoid floating point exception if size == 0 Signed-off-by: Amitay Isaacs --- src/mem.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/mem.c b/src/mem.c index 4b2c829..ce099c2 100644 --- a/src/mem.c +++ b/src/mem.c @@ -46,6 +46,11 @@ static int getmem(uint64_t addr, uint64_t size, struct mem_flags flags) uint8_t *buf; int rc = 0; + if (size == 0) { + PR_ERROR("Size must be > 0\n"); + return 1; + } + buf = malloc(size); assert(buf); pdbg_for_each_class_target("adu", target) { -- cgit v1.2.3