Skip to content

Commit

Permalink
Check the return value of realloc() for error
Browse files Browse the repository at this point in the history
	modified:   src/nms.c
  • Loading branch information
bartobri committed Sep 20, 2017
1 parent 30bd00f commit 40da205
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/nms.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 40da205

Please sign in to comment.