Correctly handle the return value of realloc

Signed-off-by: Miles Alan <m@milesalan.com>
master
Nicolai Dagestad 4 years ago committed by Miles Alan
parent b25cc35077
commit 7f977f9b2e
  1. 7
      lisgd.c

@ -294,7 +294,12 @@ main(int argc, char *argv[])
orientation = atoi(argv[++i]);
} else if (!strcmp(argv[i], "-g")) {
gestsarrlen++;
realloc(gestsarr, (gestsarrlen * sizeof(Gesture)));
void *ptr = realloc(gestsarr, (gestsarrlen * sizeof(Gesture)));
if ( ptr == NULL ) {
perror("Could not allocate memory");
exit(EXIT_FAILURE);
}
gestsarr = ptr;
gestpt = strtok(argv[++i], ",");
for (j = 0; gestpt != NULL && j < 3; gestpt = strtok(NULL, ","), j++) {
switch(j) {

Loading…
Cancel
Save