From bc92cd202e3572e0af8b012fef5f5c7b96b3db17 Mon Sep 17 00:00:00 2001 From: Calvin Date: Thu, 6 Jun 2013 12:22:05 -0400 Subject: fixed a malloc error, and fixed some strings --- src/c/quikr_train.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/c/quikr_train.c b/src/c/quikr_train.c index 86bd77e..a2f132e 100644 --- a/src/c/quikr_train.c +++ b/src/c/quikr_train.c @@ -100,7 +100,11 @@ int main(int argc, char **argv) { } if(strcmp(&output_file[strlen(output_file) - 3], ".gz") != 0) { - char *temp = malloc(sizeof(strlen(output_file) + 4)); + char *temp = malloc(strlen(output_file) + 4); + if(temp == NULL) { + fprintf(stderr, "Could not allocate enough memory\n"); + exit(EXIT_FAILURE); + } sprintf(temp, "%s.gz", output_file); output_file = temp; printf("appending a .gz to our output file: %s\n", output_file); @@ -119,7 +123,7 @@ int main(int argc, char **argv) { // Allocate our matrix with the appropriate size, just one row double *trained_matrix = malloc(width*sizeof(double)); if(trained_matrix == NULL) { - fprintf(stderr, "Could not allocated enough memory\n"); + fprintf(stderr, "Could not allocate enough memory\n"); exit(EXIT_FAILURE); } -- cgit v1.2.3