From 40da2058b4e438222e22f4b07cc9b6128da6d60d Mon Sep 17 00:00:00 2001 From: Brian Barto Date: Wed, 20 Sep 2017 09:03:45 -0400 Subject: [PATCH] Check the return value of realloc() for error modified: src/nms.c --- src/nms.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nms.c b/src/nms.c index ef2e038..fc942b4 100644 --- a/src/nms.c +++ b/src/nms.c @@ -57,6 +57,10 @@ int main(int argc, char *argv[]) { if (inSize > inCapacity) { inCapacity *= INPUT_GROWTH_FACTOR; input = realloc(input, inCapacity + 1); + if (input == NULL) { + fprintf (stderr, "Memory Allocation Error! Quitting...\n"); + return 1; + } } input[inSize - 1] = c; input[inSize] = '\0';