From b58a9260bd1422a28e4c0b7b6bb71d26603bc3e1 Mon Sep 17 00:00:00 2001 From: Christian Bauer Date: Sun, 31 Jan 2016 16:00:57 +0100 Subject: [PATCH] Add checks for realloc() result --- cxmon/src/mon_cmd.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cxmon/src/mon_cmd.cpp b/cxmon/src/mon_cmd.cpp index b708f034..4cb6a92b 100644 --- a/cxmon/src/mon_cmd.cpp +++ b/cxmon/src/mon_cmd.cpp @@ -21,6 +21,7 @@ #include "sysdeps.h" #include +#include #include "mon.h" #include "mon_cmd.h" @@ -84,11 +85,13 @@ start: if (mon_token == T_STRING) { unsigned n = strlen(mon_string); str = (uint8 *)realloc(str, (len + n - 1 + GRANULARITY) & ~(GRANULARITY - 1)); + assert(str != NULL); memcpy(str + len, mon_string, n); len += n; mon_get_token(); } else if (mon_expression(&value)) { str = (uint8 *)realloc(str, (len + GRANULARITY) & ~(GRANULARITY - 1)); + assert(str != NULL); str[len] = value; len++; } else {