From cba4934b9f5d2fa8f595ada896b1b08e1902c2c7 Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Wed, 25 May 2016 17:17:35 +0200 Subject: fixed segfault when file not found --- file_reader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/file_reader.c b/file_reader.c index c262091..e679c1c 100755 --- a/file_reader.c +++ b/file_reader.c @@ -8,9 +8,9 @@ File* file_open(const char* filename) retval->name = filename; FILE* file = fopen(retval->name, "rb"); - fseek(file, 0, SEEK_END); // go to the end of the file if(file) { + fseek(file, 0, SEEK_END); // go to the end of the file retval->size = ftell(0); // save the position (end of the file) retval->data = malloc(retval->size + 1); fseek(file, 0, SEEK_SET); // return to the beginning of the file -- cgit v1.2.3