Check the return value of realloc() for error

modified:   src/nms.c
This commit is contained in:
Brian Barto 2017-09-20 09:03:45 -04:00
parent 30bd00f949
commit 40da2058b4

View File

@ -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';