Correctly handle the return value of realloc
Signed-off-by: Miles Alan <m@milesalan.com>
This commit is contained in:
parent
b25cc35077
commit
7f977f9b2e
1 changed files with 6 additions and 1 deletions
7
lisgd.c
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…
Add table
Add a link
Reference in a new issue