From 7b0092126de3fdc24cd9cd85fcbfe3e03ec2d49b Mon Sep 17 00:00:00 2001 From: Chris Cromer Date: Sat, 8 Dec 2018 17:27:22 -0300 Subject: [PATCH] check for correct ammount of points in the file --- src/read_file.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/read_file.c b/src/read_file.c index 2763c8b..3adf7d1 100644 --- a/src/read_file.c +++ b/src/read_file.c @@ -239,6 +239,10 @@ int read_file(char *filename, point_t **points, unsigned int *n) { break; } i++; + if (j > *n) { + fprintf(stderr, "Error: Hay demasiado puntos!\n"); + return 8; + } token = strtok(NULL, " "); } } @@ -246,6 +250,10 @@ int read_file(char *filename, point_t **points, unsigned int *n) { buffer = NULL; size = 0; } + if (j < *n) { + fprintf(stderr, "Error: No hay suficiente puntos!\n"); + return 9; + } return 0; }