~jpsamaroo/lisgd

7f977f9b2e9a29d60cd9c4897b842d016784b38d — Nicolai Dagestad 3 years ago b25cc35
Correctly handle the return value of realloc

Signed-off-by: Miles Alan <m@milesalan.com>
1 files changed, 6 insertions(+), 1 deletions(-)

M lisgd.c
M lisgd.c => lisgd.c +6 -1
@@ 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) {